File tree Expand file tree Collapse file tree 1 file changed +2
-4
lines changed Expand file tree Collapse file tree 1 file changed +2
-4
lines changed Original file line number Diff line number Diff line change @@ -50,8 +50,7 @@ module JSON
5050 # Convert a UTF8 encoded Ruby string _string_ to a JSON string, encoded with
5151 # UTF16 big endian characters as \u????, and return it.
5252 def utf8_to_json ( string , script_safe = false ) # :nodoc:
53- string = string . dup
54- string . force_encoding ( ::Encoding ::ASCII_8BIT )
53+ string = string . b
5554 if script_safe
5655 string . gsub! ( SCRIPT_SAFE_ESCAPE_PATTERN ) { SCRIPT_SAFE_MAP [ $&] || $& }
5756 else
@@ -62,8 +61,7 @@ def utf8_to_json(string, script_safe = false) # :nodoc:
6261 end
6362
6463 def utf8_to_json_ascii ( string , script_safe = false ) # :nodoc:
65- string = string . dup
66- string . force_encoding ( ::Encoding ::ASCII_8BIT )
64+ string = string . b
6765 map = script_safe ? SCRIPT_SAFE_MAP : MAP
6866 string . gsub! ( /[\/ "\\ \x0 -\x1f ]/n ) { map [ $&] || $& }
6967 string . gsub! ( /(
You can’t perform that action at this time.
0 commit comments