ox 2.9.4 → 2.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/ext/ox/gen_load.c +21 -11
- data/ext/ox/hash_load.c +6 -2
- data/ext/ox/ox.c +48 -27
- data/ext/ox/ox.h +3 -0
- data/lib/ox/version.rb +1 -1
- metadata +3 -4
- data/ext/ox/encode.h +0 -26
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e1967ed8377e3a3e7ccdb8b6e14a21e5dbd0c7f435b87474c422cf3572d639a9
|
4
|
+
data.tar.gz: cdb5712d31fd0641c9f444e8ea205fb18c3ccb246ba651d31b8dbd34db7ba579
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 52f78021c4525f0c88548c2ce87a2a660d0ce60ea72ffef159611a4b39b883ce497adebf3a13c22f3c744325f4c463c4493ab66b3efbda7c975e99b0d46e7c71
|
7
|
+
data.tar.gz: b505855a76c09de2bb9c07b821b509e1d8d58ee3ce45816db6612086b10bb748dfe1c9ca07da8baab077a5ffdbc33cd3ed773fbd14f9cb7e8c2108b2e935797e
|
data/CHANGELOG.md
CHANGED
data/ext/ox/gen_load.c
CHANGED
@@ -84,10 +84,10 @@ create_doc(PInfo pi) {
|
|
84
84
|
|
85
85
|
static void
|
86
86
|
create_prolog_doc(PInfo pi, const char *target, Attr attrs) {
|
87
|
-
VALUE doc;
|
88
|
-
VALUE ah;
|
89
|
-
VALUE nodes;
|
90
|
-
VALUE sym;
|
87
|
+
volatile VALUE doc;
|
88
|
+
volatile VALUE ah;
|
89
|
+
volatile VALUE nodes;
|
90
|
+
volatile VALUE sym;
|
91
91
|
|
92
92
|
if (!helper_stack_empty(&pi->helpers)) { /* top level object */
|
93
93
|
ox_err_set(&pi->err, rb_eSyntaxError, "Prolog must be the first element in an XML document.\n");
|
@@ -96,7 +96,10 @@ create_prolog_doc(PInfo pi, const char *target, Attr attrs) {
|
|
96
96
|
doc = rb_obj_alloc(ox_document_clas);
|
97
97
|
ah = rb_hash_new();
|
98
98
|
for (; 0 != attrs->name; attrs++) {
|
99
|
-
if (
|
99
|
+
if (Qnil != pi->options->attr_key_mod) {
|
100
|
+
sym = rb_funcall(pi->options->attr_key_mod, ox_call_id, 1, rb_str_new2(attrs->name));
|
101
|
+
rb_hash_aset(ah, sym, rb_str_new2(attrs->value));
|
102
|
+
} else if (Yes == pi->options->sym_keys) {
|
100
103
|
#if HAS_ENCODING_SUPPORT
|
101
104
|
if (0 != pi->options->rb_enc) {
|
102
105
|
VALUE rstr = rb_str_new2(attrs->name);
|
@@ -120,7 +123,7 @@ create_prolog_doc(PInfo pi, const char *target, Attr attrs) {
|
|
120
123
|
#endif
|
121
124
|
rb_hash_aset(ah, sym, rb_str_new2(attrs->value));
|
122
125
|
} else {
|
123
|
-
VALUE rstr = rb_str_new2(attrs->name);
|
126
|
+
volatile VALUE rstr = rb_str_new2(attrs->name);
|
124
127
|
|
125
128
|
#if HAS_ENCODING_SUPPORT
|
126
129
|
if (0 != pi->options->rb_enc) {
|
@@ -291,6 +294,9 @@ add_element(PInfo pi, const char *ename, Attr attrs, int hasChildren) {
|
|
291
294
|
VALUE e;
|
292
295
|
VALUE s = rb_str_new2(ename);
|
293
296
|
|
297
|
+
if (Qnil != pi->options->element_key_mod) {
|
298
|
+
s = rb_funcall(pi->options->element_key_mod, ox_call_id, 1, s);
|
299
|
+
}
|
294
300
|
#if HAS_ENCODING_SUPPORT
|
295
301
|
if (0 != pi->options->rb_enc) {
|
296
302
|
rb_enc_associate(s, pi->options->rb_enc);
|
@@ -308,7 +314,9 @@ add_element(PInfo pi, const char *ename, Attr attrs, int hasChildren) {
|
|
308
314
|
for (; 0 != attrs->name; attrs++) {
|
309
315
|
volatile VALUE sym;
|
310
316
|
|
311
|
-
if (
|
317
|
+
if (Qnil != pi->options->attr_key_mod) {
|
318
|
+
sym = rb_funcall(pi->options->attr_key_mod, ox_call_id, 1, rb_str_new2(attrs->name));
|
319
|
+
} else if (Yes == pi->options->sym_keys) {
|
312
320
|
VALUE *slot;
|
313
321
|
|
314
322
|
if (Qundef == (sym = ox_cache_get(ox_symbol_cache, attrs->name, &slot, 0))) {
|
@@ -415,13 +423,15 @@ add_instruct(PInfo pi, const char *name, Attr attrs, const char *content) {
|
|
415
423
|
if (0 != content) {
|
416
424
|
rb_ivar_set(inst, ox_at_content_id, c);
|
417
425
|
} else if (0 != attrs->name) {
|
418
|
-
VALUE ah = rb_hash_new();
|
426
|
+
volatile VALUE ah = rb_hash_new();
|
419
427
|
|
420
428
|
for (; 0 != attrs->name; attrs++) {
|
421
|
-
VALUE
|
422
|
-
|
429
|
+
volatile VALUE sym;
|
430
|
+
VALUE *slot;
|
423
431
|
|
424
|
-
if (
|
432
|
+
if (Qnil != pi->options->attr_key_mod) {
|
433
|
+
sym = rb_funcall(pi->options->attr_key_mod, ox_call_id, 1, rb_str_new2(attrs->name));
|
434
|
+
} else if (Yes == pi->options->sym_keys) {
|
425
435
|
if (Qundef == (sym = ox_cache_get(ox_symbol_cache, attrs->name, &slot, 0))) {
|
426
436
|
#if HAS_ENCODING_SUPPORT
|
427
437
|
if (0 != pi->options->rb_enc) {
|
data/ext/ox/hash_load.c
CHANGED
@@ -71,7 +71,9 @@ add_element(PInfo pi, const char *ename, Attr attrs, int hasChildren) {
|
|
71
71
|
volatile VALUE a;
|
72
72
|
|
73
73
|
for (; 0 != attrs->name; attrs++) {
|
74
|
-
if (
|
74
|
+
if (Qnil != pi->options->attr_key_mod) {
|
75
|
+
key = rb_funcall(pi->options->attr_key_mod, ox_call_id, 1, rb_str_new2(attrs->name));
|
76
|
+
} else if (Yes == pi->options->sym_keys) {
|
75
77
|
key = rb_id2sym(rb_intern(attrs->name));
|
76
78
|
} else {
|
77
79
|
key = rb_str_new2(attrs->name);
|
@@ -125,7 +127,9 @@ end_element_core(PInfo pi, const char *ename, bool check_taint) {
|
|
125
127
|
if (NoCode == e->type) {
|
126
128
|
e->obj = Qnil;
|
127
129
|
}
|
128
|
-
if (
|
130
|
+
if (Qnil != pi->options->element_key_mod) {
|
131
|
+
key = rb_funcall(pi->options->element_key_mod, ox_call_id, 1, rb_id2str(e->var));
|
132
|
+
} else if (Yes == pi->options->sym_keys) {
|
129
133
|
key = rb_id2sym(e->var);
|
130
134
|
} else {
|
131
135
|
key = rb_id2str(e->var);
|
data/ext/ox/ox.c
CHANGED
@@ -40,6 +40,7 @@ ID ox_attributes_id;
|
|
40
40
|
ID ox_attrs_done_id;
|
41
41
|
ID ox_beg_id;
|
42
42
|
ID ox_bigdecimal_id;
|
43
|
+
ID ox_call_id;
|
43
44
|
ID ox_cdata_id;
|
44
45
|
ID ox_comment_id;
|
45
46
|
ID ox_den_id;
|
@@ -109,6 +110,7 @@ Cache ox_attr_cache = 0;
|
|
109
110
|
|
110
111
|
static VALUE abort_sym;
|
111
112
|
static VALUE active_sym;
|
113
|
+
static VALUE attr_key_mod_sym;
|
112
114
|
static VALUE auto_define_sym;
|
113
115
|
static VALUE auto_sym;
|
114
116
|
static VALUE block_sym;
|
@@ -145,6 +147,7 @@ static VALUE with_dtd_sym;
|
|
145
147
|
static VALUE with_instruct_sym;
|
146
148
|
static VALUE with_xml_sym;
|
147
149
|
static VALUE xsd_date_sym;
|
150
|
+
static VALUE element_key_mod_sym;
|
148
151
|
|
149
152
|
static ID encoding_id;
|
150
153
|
static ID has_key_id;
|
@@ -158,30 +161,32 @@ void *ox_utf8_encoding = 0;
|
|
158
161
|
#endif
|
159
162
|
|
160
163
|
struct _Options ox_default_options = {
|
161
|
-
{ '\0' },
|
162
|
-
{ '\0' },
|
163
|
-
2,
|
164
|
-
0,
|
165
|
-
0,
|
166
|
-
No,
|
167
|
-
No,
|
168
|
-
No,
|
169
|
-
No,
|
170
|
-
No,
|
171
|
-
NoMode,
|
172
|
-
StrictEffort,
|
173
|
-
Yes,
|
174
|
-
SpcSkip,
|
175
|
-
No,
|
176
|
-
1,
|
177
|
-
No,
|
178
|
-
{ '\0' },
|
179
|
-
{ '\0' },
|
180
|
-
NULL,
|
164
|
+
{ '\0' }, // encoding
|
165
|
+
{ '\0' }, // margin
|
166
|
+
2, // indent
|
167
|
+
0, // trace
|
168
|
+
0, // margin_len
|
169
|
+
No, // with_dtd
|
170
|
+
No, // with_xml
|
171
|
+
No, // with_instruct
|
172
|
+
No, // circular
|
173
|
+
No, // xsd_date
|
174
|
+
NoMode, // mode
|
175
|
+
StrictEffort, // effort
|
176
|
+
Yes, // sym_keys
|
177
|
+
SpcSkip, // skip
|
178
|
+
No, // smart
|
179
|
+
1, // convert_special
|
180
|
+
No, // allow_invalid
|
181
|
+
{ '\0' }, // inv_repl
|
182
|
+
{ '\0' }, // strip_ns
|
183
|
+
NULL, // html_hints
|
184
|
+
Qnil, // attr_key_mod;
|
185
|
+
Qnil, // element_key_mod;
|
181
186
|
#if HAS_PRIVATE_ENCODING
|
182
|
-
Qnil
|
187
|
+
Qnil // rb_enc
|
183
188
|
#else
|
184
|
-
0
|
189
|
+
0 // rb_enc
|
185
190
|
#endif
|
186
191
|
};
|
187
192
|
|
@@ -197,7 +202,7 @@ static void parse_dump_options(VALUE ropts, Options copts);
|
|
197
202
|
static char*
|
198
203
|
defuse_bom(char *xml, Options options) {
|
199
204
|
switch ((uint8_t)*xml) {
|
200
|
-
case 0xEF:
|
205
|
+
case 0xEF: // UTF-8
|
201
206
|
if (0xBB == (uint8_t)xml[1] && 0xBF == (uint8_t)xml[2]) {
|
202
207
|
options->rb_enc = ox_utf8_encoding;
|
203
208
|
xml += 3;
|
@@ -206,7 +211,7 @@ defuse_bom(char *xml, Options options) {
|
|
206
211
|
}
|
207
212
|
break;
|
208
213
|
#if 0
|
209
|
-
case 0xFE:
|
214
|
+
case 0xFE: // UTF-16BE
|
210
215
|
if (0xFF == (uint8_t)xml[1]) {
|
211
216
|
options->rb_enc = ox_utf16be_encoding;
|
212
217
|
xml += 2;
|
@@ -214,7 +219,7 @@ defuse_bom(char *xml, Options options) {
|
|
214
219
|
rb_raise(ox_parse_error_class, "Invalid BOM in XML string.\n");
|
215
220
|
}
|
216
221
|
break;
|
217
|
-
case 0xFF:
|
222
|
+
case 0xFF: // UTF-16LE or UTF-32LE
|
218
223
|
if (0xFE == (uint8_t)xml[1]) {
|
219
224
|
if (0x00 == (uint8_t)xml[2] && 0x00 == (uint8_t)xml[3]) {
|
220
225
|
options->rb_enc = ox_utf32le_encoding;
|
@@ -227,7 +232,7 @@ defuse_bom(char *xml, Options options) {
|
|
227
232
|
rb_raise(ox_parse_error_class, "Invalid BOM in XML string.\n");
|
228
233
|
}
|
229
234
|
break;
|
230
|
-
case 0x00:
|
235
|
+
case 0x00: // UTF-32BE
|
231
236
|
if (0x00 == (uint8_t)xml[1] && 0xFE == (uint8_t)xml[2] && 0xFF == (uint8_t)xml[3]) {
|
232
237
|
options->rb_enc = ox_utf32be_encoding;
|
233
238
|
xml += 4;
|
@@ -237,7 +242,8 @@ defuse_bom(char *xml, Options options) {
|
|
237
242
|
break;
|
238
243
|
#endif
|
239
244
|
default:
|
240
|
-
|
245
|
+
// Let it fail if there is a BOM that is not UTF-8. Other BOM options
|
246
|
+
// are not ASCII compatible.
|
241
247
|
break;
|
242
248
|
}
|
243
249
|
return xml;
|
@@ -280,6 +286,8 @@ hints_to_overlay(Hints hints) {
|
|
280
286
|
* - _:mode_ [:object|:generic|:limited|:hash|:hash_no_attrs|nil] load method to use for XML
|
281
287
|
* - _:effort_ [:strict|:tolerant|:auto_define] set the tolerance level for loading
|
282
288
|
* - _:symbolize_keys_ [true|false|nil] symbolize element attribute keys or leave as Strings
|
289
|
+
* - _:element_key_mod_ [Proc|nil] converts element keys on parse if not nil
|
290
|
+
* - _:attr_key_mod_ [Proc|nil] converts attribute keys on parse if not nil
|
283
291
|
* - _:skip_ [:skip_none|:skip_return|:skip_white|:skip_off] determines how to handle white space in text
|
284
292
|
* - _:smart_ [true|false|nil] flag indicating the SAX parser uses hints if available (use with html)
|
285
293
|
* - _:convert_special_ [true|false|nil] flag indicating special characters like < are converted with the SAX parser
|
@@ -313,6 +321,8 @@ get_def_opts(VALUE self) {
|
|
313
321
|
rb_hash_aset(opts, circular_sym, (Yes == ox_default_options.circular) ? Qtrue : ((No == ox_default_options.circular) ? Qfalse : Qnil));
|
314
322
|
rb_hash_aset(opts, xsd_date_sym, (Yes == ox_default_options.xsd_date) ? Qtrue : ((No == ox_default_options.xsd_date) ? Qfalse : Qnil));
|
315
323
|
rb_hash_aset(opts, symbolize_keys_sym, (Yes == ox_default_options.sym_keys) ? Qtrue : ((No == ox_default_options.sym_keys) ? Qfalse : Qnil));
|
324
|
+
rb_hash_aset(opts, attr_key_mod_sym, ox_default_options.attr_key_mod);
|
325
|
+
rb_hash_aset(opts, element_key_mod_sym, ox_default_options.element_key_mod);
|
316
326
|
rb_hash_aset(opts, smart_sym, (Yes == ox_default_options.smart) ? Qtrue : ((No == ox_default_options.smart) ? Qfalse : Qnil));
|
317
327
|
rb_hash_aset(opts, convert_special_sym, (ox_default_options.convert_special) ? Qtrue : Qfalse);
|
318
328
|
switch (ox_default_options.mode) {
|
@@ -416,6 +426,8 @@ sax_html_overlay(VALUE self) {
|
|
416
426
|
* - _:mode_ [:object|:generic|:limited|:hash|:hash_no_attrs|nil] load method to use for XML
|
417
427
|
* - _:effort_ [:strict|:tolerant|:auto_define] set the tolerance level for loading
|
418
428
|
* - _:symbolize_keys_ [true|false|nil] symbolize element attribute keys or leave as Strings
|
429
|
+
* - _:element_key_mod_ [Proc|nil] converts element keys on parse if not nil
|
430
|
+
* - _:attr_key_mod_ [Proc|nil] converts attribute keys on parse if not nil
|
419
431
|
* - _:skip_ [:skip_none|:skip_return|:skip_white|:skip_off] determines how to handle white space in text
|
420
432
|
* - _:smart_ [true|false|nil] flag indicating the SAX parser uses hints if available (use with html)
|
421
433
|
* - _:invalid_replace_ [nil|String] replacement string for invalid XML characters on dump. nil indicates include anyway as hex. A string, limited to 10 characters will replace the invalid character with the replace.
|
@@ -611,6 +623,9 @@ set_def_opts(VALUE self, VALUE opts) {
|
|
611
623
|
rb_hash_foreach(v, set_overlay, (VALUE)ox_default_options.html_hints);
|
612
624
|
}
|
613
625
|
}
|
626
|
+
ox_default_options.element_key_mod = rb_hash_lookup2(opts, element_key_mod_sym, ox_default_options.element_key_mod);
|
627
|
+
ox_default_options.attr_key_mod = rb_hash_lookup2(opts, attr_key_mod_sym, ox_default_options.attr_key_mod);
|
628
|
+
|
614
629
|
return Qnil;
|
615
630
|
}
|
616
631
|
|
@@ -755,6 +770,9 @@ load(char *xml, size_t len, int argc, VALUE *argv, VALUE self, VALUE encoding, E
|
|
755
770
|
if (Qnil != (v = rb_hash_lookup(h, symbolize_keys_sym))) {
|
756
771
|
options.sym_keys = (Qfalse == v) ? No : Yes;
|
757
772
|
}
|
773
|
+
options.element_key_mod = rb_hash_lookup2(h, element_key_mod_sym, options.element_key_mod);
|
774
|
+
options.attr_key_mod = rb_hash_lookup2(h, attr_key_mod_sym, options.attr_key_mod);
|
775
|
+
|
758
776
|
if (Qnil != (v = rb_hash_lookup(h, convert_special_sym))) {
|
759
777
|
options.convert_special = (Qfalse != v);
|
760
778
|
}
|
@@ -1379,6 +1397,7 @@ void Init_ox() {
|
|
1379
1397
|
ox_attrs_done_id = rb_intern("attrs_done");
|
1380
1398
|
ox_beg_id = rb_intern("@beg");
|
1381
1399
|
ox_bigdecimal_id = rb_intern("BigDecimal");
|
1400
|
+
ox_call_id = rb_intern("call");
|
1382
1401
|
ox_cdata_id = rb_intern("cdata");
|
1383
1402
|
ox_comment_id = rb_intern("comment");
|
1384
1403
|
ox_den_id = rb_intern("@den");
|
@@ -1442,12 +1461,14 @@ void Init_ox() {
|
|
1442
1461
|
|
1443
1462
|
abort_sym = ID2SYM(rb_intern("abort")); rb_gc_register_address(&abort_sym);
|
1444
1463
|
active_sym = ID2SYM(rb_intern("active")); rb_gc_register_address(&active_sym);
|
1464
|
+
attr_key_mod_sym = ID2SYM(rb_intern("attr_key_mod")); rb_gc_register_address(&attr_key_mod_sym);
|
1445
1465
|
auto_define_sym = ID2SYM(rb_intern("auto_define")); rb_gc_register_address(&auto_define_sym);
|
1446
1466
|
auto_sym = ID2SYM(rb_intern("auto")); rb_gc_register_address(&auto_sym);
|
1447
1467
|
block_sym = ID2SYM(rb_intern("block")); rb_gc_register_address(&block_sym);
|
1448
1468
|
circular_sym = ID2SYM(rb_intern("circular")); rb_gc_register_address(&circular_sym);
|
1449
1469
|
convert_special_sym = ID2SYM(rb_intern("convert_special")); rb_gc_register_address(&convert_special_sym);
|
1450
1470
|
effort_sym = ID2SYM(rb_intern("effort")); rb_gc_register_address(&effort_sym);
|
1471
|
+
element_key_mod_sym = ID2SYM(rb_intern("element_key_mod")); rb_gc_register_address(&element_key_mod_sym);
|
1451
1472
|
generic_sym = ID2SYM(rb_intern("generic")); rb_gc_register_address(&generic_sym);
|
1452
1473
|
hash_no_attrs_sym = ID2SYM(rb_intern("hash_no_attrs")); rb_gc_register_address(&hash_no_attrs_sym);
|
1453
1474
|
hash_sym = ID2SYM(rb_intern("hash")); rb_gc_register_address(&hash_sym);
|
data/ext/ox/ox.h
CHANGED
@@ -143,6 +143,8 @@ typedef struct _Options {
|
|
143
143
|
char inv_repl[12]; /* max 10 valid characters, first character is the length */
|
144
144
|
char strip_ns[64]; /* namespace to strip, \0 is no-strip, \* is all, else only matches */
|
145
145
|
struct _Hints *html_hints; /* html hints */
|
146
|
+
VALUE attr_key_mod;
|
147
|
+
VALUE element_key_mod;
|
146
148
|
#if HAS_ENCODING_SUPPORT
|
147
149
|
rb_encoding *rb_enc;
|
148
150
|
#elif HAS_PRIVATE_ENCODING
|
@@ -192,6 +194,7 @@ extern ID ox_attrs_done_id;
|
|
192
194
|
extern ID ox_attributes_id;
|
193
195
|
extern ID ox_beg_id;
|
194
196
|
extern ID ox_bigdecimal_id;
|
197
|
+
extern ID ox_call_id;
|
195
198
|
extern ID ox_cdata_id;
|
196
199
|
extern ID ox_comment_id;
|
197
200
|
extern ID ox_den_id;
|
data/lib/ox/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Ohler
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-09-03 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: "A fast XML parser and object serializer that uses only standard C lib.\n
|
14
14
|
\ \nOptimized XML (Ox), as the name implies was written to provide speed
|
@@ -35,7 +35,6 @@ files:
|
|
35
35
|
- ext/ox/cache8.c
|
36
36
|
- ext/ox/cache8.h
|
37
37
|
- ext/ox/dump.c
|
38
|
-
- ext/ox/encode.h
|
39
38
|
- ext/ox/err.c
|
40
39
|
- ext/ox/err.h
|
41
40
|
- ext/ox/extconf.rb
|
@@ -100,7 +99,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
100
99
|
version: '0'
|
101
100
|
requirements: []
|
102
101
|
rubyforge_project: ox
|
103
|
-
rubygems_version: 2.7.
|
102
|
+
rubygems_version: 2.7.6
|
104
103
|
signing_key:
|
105
104
|
specification_version: 4
|
106
105
|
summary: A fast XML parser and object serializer.
|
data/ext/ox/encode.h
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
/* encode.h
|
2
|
-
* Copyright (c) 2011, Peter Ohler
|
3
|
-
* All rights reserved.
|
4
|
-
*/
|
5
|
-
|
6
|
-
#ifndef __OX_ENCODE_H__
|
7
|
-
#define __OX_ENCODE_H__
|
8
|
-
|
9
|
-
#include "ruby.h"
|
10
|
-
#if HAS_ENCODING_SUPPORT
|
11
|
-
#include "ruby/encoding.h"
|
12
|
-
#endif
|
13
|
-
|
14
|
-
static inline VALUE
|
15
|
-
ox_encode(VALUE rstr) {
|
16
|
-
#if HAS_ENCODING_SUPPORT
|
17
|
-
rb_enc_associate(rstr, ox_utf8_encoding);
|
18
|
-
#else
|
19
|
-
if (Qnil != ox_utf8_encoding) {
|
20
|
-
rstr = rb_funcall(ox_utf8_encoding, ox_iconv_id, 1, rstr);
|
21
|
-
}
|
22
|
-
#endif
|
23
|
-
return rstr;
|
24
|
-
}
|
25
|
-
|
26
|
-
#endif /* __OX_ENCODE_H__ */
|