json_pure 1.8.6 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +0 -1
  3. data/.travis.yml +5 -3
  4. data/CHANGES +5 -5
  5. data/Gemfile +3 -1
  6. data/README.md +131 -84
  7. data/Rakefile +17 -10
  8. data/VERSION +1 -1
  9. data/ext/json/ext/generator/generator.c +1 -52
  10. data/ext/json/ext/generator/generator.h +0 -5
  11. data/ext/json/ext/parser/extconf.rb +3 -0
  12. data/ext/json/ext/parser/parser.c +304 -458
  13. data/ext/json/ext/parser/parser.h +0 -1
  14. data/ext/json/ext/parser/parser.rl +35 -152
  15. data/ext/json/extconf.rb +0 -1
  16. data/java/src/json/ext/Generator.java +2 -5
  17. data/java/src/json/ext/GeneratorState.java +2 -54
  18. data/java/src/json/ext/OptionsReader.java +1 -1
  19. data/java/src/json/ext/Parser.java +109 -409
  20. data/java/src/json/ext/Parser.rl +24 -117
  21. data/java/src/json/ext/RuntimeInfo.java +0 -4
  22. data/json.gemspec +0 -0
  23. data/json_pure.gemspec +7 -7
  24. data/lib/json.rb +1 -0
  25. data/lib/json/add/bigdecimal.rb +1 -0
  26. data/lib/json/add/complex.rb +2 -1
  27. data/lib/json/add/core.rb +1 -0
  28. data/lib/json/add/date.rb +1 -1
  29. data/lib/json/add/date_time.rb +1 -1
  30. data/lib/json/add/exception.rb +1 -1
  31. data/lib/json/add/ostruct.rb +1 -1
  32. data/lib/json/add/range.rb +1 -1
  33. data/lib/json/add/rational.rb +1 -0
  34. data/lib/json/add/regexp.rb +1 -1
  35. data/lib/json/add/struct.rb +1 -1
  36. data/lib/json/add/symbol.rb +1 -1
  37. data/lib/json/add/time.rb +1 -1
  38. data/lib/json/common.rb +24 -52
  39. data/lib/json/ext.rb +0 -6
  40. data/lib/json/generic_object.rb +5 -4
  41. data/lib/json/pure.rb +2 -8
  42. data/lib/json/pure/generator.rb +51 -123
  43. data/lib/json/pure/parser.rb +28 -80
  44. data/lib/json/version.rb +2 -1
  45. data/references/rfc7159.txt +899 -0
  46. data/tests/fixtures/obsolete_fail1.json +1 -0
  47. data/tests/{test_json_addition.rb → json_addition_test.rb} +22 -25
  48. data/tests/json_common_interface_test.rb +126 -0
  49. data/tests/json_encoding_test.rb +105 -0
  50. data/tests/json_ext_parser_test.rb +15 -0
  51. data/tests/{test_json_fixtures.rb → json_fixtures_test.rb} +5 -8
  52. data/tests/{test_json_generate.rb → json_generator_test.rb} +65 -37
  53. data/tests/{test_json_generic_object.rb → json_generic_object_test.rb} +15 -8
  54. data/tests/json_parser_test.rb +448 -0
  55. data/tests/json_string_matching_test.rb +38 -0
  56. data/tests/test_helper.rb +23 -0
  57. data/tools/fuzz.rb +1 -9
  58. metadata +18 -31
  59. data/TODO +0 -1
  60. data/tests/fixtures/fail1.json +0 -1
  61. data/tests/setup_variant.rb +0 -11
  62. data/tests/test_json.rb +0 -519
  63. data/tests/test_json_encoding.rb +0 -65
  64. data/tests/test_json_string_matching.rb +0 -39
  65. data/tests/test_json_unicode.rb +0 -72
@@ -38,7 +38,6 @@ typedef struct JSON_ParserStruct {
38
38
  int allow_nan;
39
39
  int parsing_name;
40
40
  int symbolize_names;
41
- int quirks_mode;
42
41
  VALUE object_class;
43
42
  VALUE array_class;
44
43
  int create_additions;
@@ -2,7 +2,7 @@
2
2
  #include "parser.h"
3
3
 
4
4
  #if defined HAVE_RUBY_ENCODING_H
5
- # define EXC_ENCODING UTF_8,
5
+ # define EXC_ENCODING rb_utf8_encoding(),
6
6
  # ifndef HAVE_RB_ENC_RAISE
7
7
  static void
8
8
  enc_raise(rb_encoding *enc, VALUE exc, const char *fmt, ...)
@@ -87,17 +87,11 @@ static int convert_UTF32_to_UTF8(char *buf, UTF32 ch)
87
87
  return len;
88
88
  }
89
89
 
90
- #ifdef HAVE_RUBY_ENCODING_H
91
- static rb_encoding *UTF_8, *UTF_16BE, *UTF_16LE, *UTF_32BE, *UTF_32LE;
92
- #else
93
- static ID i_iconv;
94
- #endif
95
-
96
90
  static VALUE mJSON, mExt, cParser, eParserError, eNestingError;
97
91
  static VALUE CNaN, CInfinity, CMinusInfinity;
98
92
 
99
93
  static ID i_json_creatable_p, i_json_create, i_create_id, i_create_additions,
100
- i_chr, i_max_nesting, i_allow_nan, i_symbolize_names, i_quirks_mode,
94
+ i_chr, i_max_nesting, i_allow_nan, i_symbolize_names,
101
95
  i_object_class, i_array_class, i_key_p, i_deep_const_get, i_match,
102
96
  i_match_string, i_aset, i_aref, i_leftshift;
103
97
 
@@ -243,7 +237,7 @@ static char *JSON_parse_object(JSON_Parser *json, char *p, char *pe, VALUE *resu
243
237
 
244
238
  action parse_number {
245
239
  char *np;
246
- if(pe > fpc + 9 - json->quirks_mode && !strncmp(MinusInfinity, fpc, 9)) {
240
+ if(pe > fpc + 8 && !strncmp(MinusInfinity, fpc, 9)) {
247
241
  if (json->allow_nan) {
248
242
  *result = CMinusInfinity;
249
243
  fexec p + 10;
@@ -277,7 +271,7 @@ static char *JSON_parse_object(JSON_Parser *json, char *p, char *pe, VALUE *resu
277
271
 
278
272
  action exit { fhold; fbreak; }
279
273
 
280
- main := (
274
+ main := ignore* (
281
275
  Vnull @parse_null |
282
276
  Vfalse @parse_false |
283
277
  Vtrue @parse_true |
@@ -287,7 +281,7 @@ main := (
287
281
  begin_string >parse_string |
288
282
  begin_array >parse_array |
289
283
  begin_object >parse_object
290
- ) %*exit;
284
+ ) ignore* %*exit;
291
285
  }%%
292
286
 
293
287
  static char *JSON_parse_value(JSON_Parser *json, char *p, char *pe, VALUE *result)
@@ -548,6 +542,8 @@ static char *JSON_parse_string(JSON_Parser *json, char *p, char *pe, VALUE *resu
548
542
 
549
543
  if (json->symbolize_names && json->parsing_name) {
550
544
  *result = rb_str_intern(*result);
545
+ } else {
546
+ rb_str_resize(*result, RSTRING_LEN(*result));
551
547
  }
552
548
  if (cs >= JSON_string_first_final) {
553
549
  return p + 1;
@@ -570,41 +566,13 @@ static char *JSON_parse_string(JSON_Parser *json, char *p, char *pe, VALUE *resu
570
566
 
571
567
  static VALUE convert_encoding(VALUE source)
572
568
  {
573
- const char *ptr = RSTRING_PTR(source);
574
- long len = RSTRING_LEN(source);
575
- if (len < 2) {
576
- rb_raise(eParserError, "A JSON text must at least contain two octets!");
577
- }
578
569
  #ifdef HAVE_RUBY_ENCODING_H
579
- {
580
- rb_encoding *enc = rb_enc_get(source);
581
- if (enc == rb_ascii8bit_encoding()) {
582
- if (len >= 4 && ptr[0] == 0 && ptr[1] == 0 && ptr[2] == 0) {
583
- source = rb_str_conv_enc(source, UTF_32BE, rb_utf8_encoding());
584
- } else if (len >= 4 && ptr[0] == 0 && ptr[2] == 0) {
585
- source = rb_str_conv_enc(source, UTF_16BE, rb_utf8_encoding());
586
- } else if (len >= 4 && ptr[1] == 0 && ptr[2] == 0 && ptr[3] == 0) {
587
- source = rb_str_conv_enc(source, UTF_32LE, rb_utf8_encoding());
588
- } else if (len >= 4 && ptr[1] == 0 && ptr[3] == 0) {
589
- source = rb_str_conv_enc(source, UTF_16LE, rb_utf8_encoding());
590
- } else {
591
- source = rb_str_dup(source);
592
- FORCE_UTF8(source);
593
- }
594
- } else {
595
- source = rb_str_conv_enc(source, rb_enc_get(source), rb_utf8_encoding());
596
- }
597
- }
598
- #else
599
- if (len >= 4 && ptr[0] == 0 && ptr[1] == 0 && ptr[2] == 0) {
600
- source = rb_funcall(mJSON, i_iconv, 3, rb_str_new2("utf-8"), rb_str_new2("utf-32be"), source);
601
- } else if (len >= 4 && ptr[0] == 0 && ptr[2] == 0) {
602
- source = rb_funcall(mJSON, i_iconv, 3, rb_str_new2("utf-8"), rb_str_new2("utf-16be"), source);
603
- } else if (len >= 4 && ptr[1] == 0 && ptr[2] == 0 && ptr[3] == 0) {
604
- source = rb_funcall(mJSON, i_iconv, 3, rb_str_new2("utf-8"), rb_str_new2("utf-32le"), source);
605
- } else if (len >= 4 && ptr[1] == 0 && ptr[3] == 0) {
606
- source = rb_funcall(mJSON, i_iconv, 3, rb_str_new2("utf-8"), rb_str_new2("utf-16le"), source);
607
- }
570
+ rb_encoding *enc = rb_enc_get(source);
571
+ if (enc == rb_ascii8bit_encoding()) {
572
+ FORCE_UTF8(source);
573
+ } else {
574
+ source = rb_str_conv_enc(source, NULL, rb_utf8_encoding());
575
+ }
608
576
  #endif
609
577
  return source;
610
578
  }
@@ -627,8 +595,9 @@ static VALUE convert_encoding(VALUE source)
627
595
  * defiance of RFC 4627 to be parsed by the Parser. This option defaults to
628
596
  * false.
629
597
  * * *symbolize_names*: If set to true, returns symbols for the names
630
- * (keys) in a JSON object. Otherwise strings are returned, which is also
631
- * the default.
598
+ * (keys) in a JSON object. Otherwise strings are returned, which is
599
+ * also the default. It's not possible to use this option in
600
+ * conjunction with the *create_additions* option.
632
601
  * * *create_additions*: If set to false, the Parser doesn't create
633
602
  * additions even if a matching class and create_id was found. This option
634
603
  * defaults to false.
@@ -679,19 +648,17 @@ static VALUE cParser_initialize(int argc, VALUE *argv, VALUE self)
679
648
  } else {
680
649
  json->symbolize_names = 0;
681
650
  }
682
- tmp = ID2SYM(i_quirks_mode);
683
- if (option_given_p(opts, tmp)) {
684
- VALUE quirks_mode = rb_hash_aref(opts, tmp);
685
- json->quirks_mode = RTEST(quirks_mode) ? 1 : 0;
686
- } else {
687
- json->quirks_mode = 0;
688
- }
689
651
  tmp = ID2SYM(i_create_additions);
690
652
  if (option_given_p(opts, tmp)) {
691
653
  json->create_additions = RTEST(rb_hash_aref(opts, tmp));
692
654
  } else {
693
655
  json->create_additions = 0;
694
656
  }
657
+ if (json->symbolize_names && json->create_additions) {
658
+ rb_raise(rb_eArgError,
659
+ "options :symbolize_names and :create_additions cannot be "
660
+ " used in conjunction");
661
+ }
695
662
  tmp = ID2SYM(i_create_id);
696
663
  if (option_given_p(opts, tmp)) {
697
664
  json->create_id = rb_hash_aref(opts, tmp);
@@ -728,11 +695,9 @@ static VALUE cParser_initialize(int argc, VALUE *argv, VALUE self)
728
695
  json->object_class = Qnil;
729
696
  json->array_class = Qnil;
730
697
  }
731
- StringValue(source);
732
- if (!json->quirks_mode) {
733
- source = convert_encoding(source);
734
- }
698
+ source = convert_encoding(StringValue(source));
735
699
  json->current_nesting = 0;
700
+ StringValue(source);
736
701
  json->len = RSTRING_LEN(source);
737
702
  json->source = RSTRING_PTR(source);;
738
703
  json->Vsource = source;
@@ -746,54 +711,6 @@ static VALUE cParser_initialize(int argc, VALUE *argv, VALUE self)
746
711
 
747
712
  include JSON_common;
748
713
 
749
- action parse_object {
750
- char *np;
751
- json->current_nesting = 1;
752
- np = JSON_parse_object(json, fpc, pe, &result);
753
- if (np == NULL) { fhold; fbreak; } else fexec np;
754
- }
755
-
756
- action parse_array {
757
- char *np;
758
- json->current_nesting = 1;
759
- np = JSON_parse_array(json, fpc, pe, &result);
760
- if (np == NULL) { fhold; fbreak; } else fexec np;
761
- }
762
-
763
- main := ignore* (
764
- begin_object >parse_object |
765
- begin_array >parse_array
766
- ) ignore*;
767
- }%%
768
-
769
- static VALUE cParser_parse_strict(VALUE self)
770
- {
771
- char *p, *pe;
772
- int cs = EVIL;
773
- VALUE result = Qnil;
774
- GET_PARSER;
775
-
776
- %% write init;
777
- p = json->source;
778
- pe = p + json->len;
779
- %% write exec;
780
-
781
- if (cs >= JSON_first_final && p == pe) {
782
- return result;
783
- } else {
784
- rb_enc_raise(EXC_ENCODING eParserError, "%u: unexpected token at '%s'", __LINE__, p);
785
- return Qnil;
786
- }
787
- }
788
-
789
-
790
- %%{
791
- machine JSON_quirks_mode;
792
-
793
- write data;
794
-
795
- include JSON_common;
796
-
797
714
  action parse_value {
798
715
  char *np = JSON_parse_value(json, fpc, pe, &result);
799
716
  if (np == NULL) { fhold; fbreak; } else fexec np;
@@ -804,26 +721,6 @@ static VALUE cParser_parse_strict(VALUE self)
804
721
  ) ignore*;
805
722
  }%%
806
723
 
807
- static VALUE cParser_parse_quirks_mode(VALUE self)
808
- {
809
- char *p, *pe;
810
- int cs = EVIL;
811
- VALUE result = Qnil;
812
- GET_PARSER;
813
-
814
- %% write init;
815
- p = json->source;
816
- pe = p + json->len;
817
- %% write exec;
818
-
819
- if (cs >= JSON_quirks_mode_first_final && p == pe) {
820
- return result;
821
- } else {
822
- rb_enc_raise(EXC_ENCODING eParserError, "%u: unexpected token at '%s'", __LINE__, p);
823
- return Qnil;
824
- }
825
- }
826
-
827
724
  /*
828
725
  * call-seq: parse()
829
726
  *
@@ -832,12 +729,21 @@ static VALUE cParser_parse_quirks_mode(VALUE self)
832
729
  */
833
730
  static VALUE cParser_parse(VALUE self)
834
731
  {
732
+ char *p, *pe;
733
+ int cs = EVIL;
734
+ VALUE result = Qnil;
835
735
  GET_PARSER;
836
736
 
837
- if (json->quirks_mode) {
838
- return cParser_parse_quirks_mode(self);
737
+ %% write init;
738
+ p = json->source;
739
+ pe = p + json->len;
740
+ %% write exec;
741
+
742
+ if (cs >= JSON_first_final && p == pe) {
743
+ return result;
839
744
  } else {
840
- return cParser_parse_strict(self);
745
+ rb_enc_raise(EXC_ENCODING eParserError, "%u: unexpected token at '%s'", __LINE__, p);
746
+ return Qnil;
841
747
  }
842
748
  }
843
749
 
@@ -895,18 +801,6 @@ static VALUE cParser_source(VALUE self)
895
801
  return rb_str_dup(json->Vsource);
896
802
  }
897
803
 
898
- /*
899
- * call-seq: quirks_mode?()
900
- *
901
- * Returns a true, if this parser is in quirks_mode, false otherwise.
902
- */
903
- static VALUE cParser_quirks_mode_p(VALUE self)
904
- {
905
- GET_PARSER;
906
- return json->quirks_mode ? Qtrue : Qfalse;
907
- }
908
-
909
-
910
804
  void Init_parser(void)
911
805
  {
912
806
  rb_require("json/common");
@@ -919,7 +813,6 @@ void Init_parser(void)
919
813
  rb_define_method(cParser, "initialize", cParser_initialize, -1);
920
814
  rb_define_method(cParser, "parse", cParser_parse, 0);
921
815
  rb_define_method(cParser, "source", cParser_source, 0);
922
- rb_define_method(cParser, "quirks_mode?", cParser_quirks_mode_p, 0);
923
816
 
924
817
  CNaN = rb_const_get(mJSON, rb_intern("NaN"));
925
818
  CInfinity = rb_const_get(mJSON, rb_intern("Infinity"));
@@ -933,7 +826,6 @@ void Init_parser(void)
933
826
  i_max_nesting = rb_intern("max_nesting");
934
827
  i_allow_nan = rb_intern("allow_nan");
935
828
  i_symbolize_names = rb_intern("symbolize_names");
936
- i_quirks_mode = rb_intern("quirks_mode");
937
829
  i_object_class = rb_intern("object_class");
938
830
  i_array_class = rb_intern("array_class");
939
831
  i_match = rb_intern("match");
@@ -943,15 +835,6 @@ void Init_parser(void)
943
835
  i_aset = rb_intern("[]=");
944
836
  i_aref = rb_intern("[]");
945
837
  i_leftshift = rb_intern("<<");
946
- #ifdef HAVE_RUBY_ENCODING_H
947
- UTF_8 = rb_utf8_encoding();
948
- UTF_16BE = rb_enc_find("utf-16be");
949
- UTF_16LE = rb_enc_find("utf-16le");
950
- UTF_32BE = rb_enc_find("utf-32be");
951
- UTF_32LE = rb_enc_find("utf-32le");
952
- #else
953
- i_iconv = rb_intern("iconv");
954
- #endif
955
838
  }
956
839
 
957
840
  /*
@@ -1,3 +1,2 @@
1
1
  require 'mkmf'
2
2
  create_makefile('json')
3
-
@@ -172,9 +172,7 @@ public final class Generator {
172
172
  result = RubyString.newString(session.getRuntime(), buffer);
173
173
  ThreadContext context = session.getContext();
174
174
  RuntimeInfo info = session.getInfo();
175
- if (info.encodingsSupported()) {
176
- result.force_encoding(context, info.utf8.get());
177
- }
175
+ result.force_encoding(context, info.utf8.get());
178
176
  return result;
179
177
  }
180
178
 
@@ -381,8 +379,7 @@ public final class Generator {
381
379
  RuntimeInfo info = session.getInfo();
382
380
  RubyString src;
383
381
 
384
- if (info.encodingsSupported() &&
385
- object.encoding(session.getContext()) != info.utf8.get()) {
382
+ if (object.encoding(session.getContext()) != info.utf8.get()) {
386
383
  src = (RubyString)object.encode(session.getContext(),
387
384
  info.utf8.get());
388
385
  } else {
@@ -207,45 +207,11 @@ public class GeneratorState extends RubyObject {
207
207
  @JRubyMethod
208
208
  public IRubyObject generate(ThreadContext context, IRubyObject obj) {
209
209
  RubyString result = Generator.generateJson(context, obj, this);
210
- if (!quirksMode && !objectOrArrayLiteral(result)) {
211
- throw Utils.newException(context, Utils.M_GENERATOR_ERROR,
212
- "only generation of JSON objects or arrays allowed");
213
- }
214
210
  RuntimeInfo info = RuntimeInfo.forRuntime(context.getRuntime());
215
- if (info.encodingsSupported()) {
216
- result.force_encoding(context, info.utf8.get());
217
- }
211
+ result.force_encoding(context, info.utf8.get());
218
212
  return result;
219
213
  }
220
214
 
221
- /**
222
- * Ensures the given string is in the form "[...]" or "{...}", being
223
- * possibly surrounded by white space.
224
- * The string's encoding must be ASCII-compatible.
225
- * @param value
226
- * @return
227
- */
228
- private static boolean objectOrArrayLiteral(RubyString value) {
229
- ByteList bl = value.getByteList();
230
- int len = bl.length();
231
-
232
- for (int pos = 0; pos < len - 1; pos++) {
233
- int b = bl.get(pos);
234
- if (Character.isWhitespace(b)) continue;
235
-
236
- // match the opening brace
237
- switch (b) {
238
- case '[':
239
- return matchClosingBrace(bl, pos, len, ']');
240
- case '{':
241
- return matchClosingBrace(bl, pos, len, '}');
242
- default:
243
- return false;
244
- }
245
- }
246
- return false;
247
- }
248
-
249
215
  private static boolean matchClosingBrace(ByteList bl, int pos, int len,
250
216
  int brace) {
251
217
  for (int endPos = len - 1; endPos > pos; endPos--) {
@@ -398,17 +364,6 @@ public class GeneratorState extends RubyObject {
398
364
  return context.getRuntime().newBoolean(asciiOnly);
399
365
  }
400
366
 
401
- @JRubyMethod(name="quirks_mode")
402
- public RubyBoolean quirks_mode_get(ThreadContext context) {
403
- return context.getRuntime().newBoolean(quirksMode);
404
- }
405
-
406
- @JRubyMethod(name="quirks_mode=")
407
- public IRubyObject quirks_mode_set(IRubyObject quirks_mode) {
408
- quirksMode = quirks_mode.isTrue();
409
- return quirks_mode.getRuntime().newBoolean(quirksMode);
410
- }
411
-
412
367
  @JRubyMethod(name="buffer_initial_length")
413
368
  public RubyInteger buffer_initial_length_get(ThreadContext context) {
414
369
  return context.getRuntime().newFixnum(bufferInitialLength);
@@ -421,11 +376,6 @@ public class GeneratorState extends RubyObject {
421
376
  return buffer_initial_length;
422
377
  }
423
378
 
424
- @JRubyMethod(name="quirks_mode?")
425
- public RubyBoolean quirks_mode_p(ThreadContext context) {
426
- return context.getRuntime().newBoolean(quirksMode);
427
- }
428
-
429
379
  public int getDepth() {
430
380
  return depth;
431
381
  }
@@ -444,7 +394,7 @@ public class GeneratorState extends RubyObject {
444
394
  private ByteList prepareByteList(ThreadContext context, IRubyObject value) {
445
395
  RubyString str = value.convertToString();
446
396
  RuntimeInfo info = RuntimeInfo.forRuntime(context.getRuntime());
447
- if (info.encodingsSupported() && str.encoding(context) != info.utf8.get()) {
397
+ if (str.encoding(context) != info.utf8.get()) {
448
398
  str = (RubyString)str.encode(context, info.utf8.get());
449
399
  }
450
400
  return str.getByteList().dup();
@@ -480,7 +430,6 @@ public class GeneratorState extends RubyObject {
480
430
  maxNesting = opts.getInt("max_nesting", DEFAULT_MAX_NESTING);
481
431
  allowNaN = opts.getBool("allow_nan", DEFAULT_ALLOW_NAN);
482
432
  asciiOnly = opts.getBool("ascii_only", DEFAULT_ASCII_ONLY);
483
- quirksMode = opts.getBool("quirks_mode", DEFAULT_QUIRKS_MODE);
484
433
  bufferInitialLength = opts.getInt("buffer_initial_length", DEFAULT_BUFFER_INITIAL_LENGTH);
485
434
 
486
435
  depth = opts.getInt("depth", 0);
@@ -507,7 +456,6 @@ public class GeneratorState extends RubyObject {
507
456
  result.op_aset(context, runtime.newSymbol("array_nl"), array_nl_get(context));
508
457
  result.op_aset(context, runtime.newSymbol("allow_nan"), allow_nan_p(context));
509
458
  result.op_aset(context, runtime.newSymbol("ascii_only"), ascii_only_p(context));
510
- result.op_aset(context, runtime.newSymbol("quirks_mode"), quirks_mode_p(context));
511
459
  result.op_aset(context, runtime.newSymbol("max_nesting"), max_nesting_get(context));
512
460
  result.op_aset(context, runtime.newSymbol("depth"), depth_get(context));
513
461
  result.op_aset(context, runtime.newSymbol("buffer_initial_length"), buffer_initial_length_get(context));
@@ -84,7 +84,7 @@ final class OptionsReader {
84
84
 
85
85
  RubyString str = value.convertToString();
86
86
  RuntimeInfo info = getRuntimeInfo();
87
- if (info.encodingsSupported() && str.encoding(context) != info.utf8.get()) {
87
+ if (str.encoding(context) != info.utf8.get()) {
88
88
  str = (RubyString)str.encode(context, info.utf8.get());
89
89
  }
90
90
  return str;