mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* ext/json/lib/json/pure/generator.rb (utf8_to_json):
force_encoding before gsub. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19704 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
6d58b1e54f
commit
84f677d2f3
2 changed files with 7 additions and 2 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
Tue Oct 7 16:43:51 2008 NARUSE, Yui <naruse@ruby-lang.org>
|
||||||
|
|
||||||
|
* ext/json/lib/json/pure/generator.rb (utf8_to_json):
|
||||||
|
force_encoding before gsub.
|
||||||
|
|
||||||
Tue Oct 7 16:35:41 2008 NARUSE, Yui <naruse@ruby-lang.org>
|
Tue Oct 7 16:35:41 2008 NARUSE, Yui <naruse@ruby-lang.org>
|
||||||
|
|
||||||
* ext/json/lib/json/pure/generator.rb (utf8_to_json):
|
* ext/json/lib/json/pure/generator.rb (utf8_to_json):
|
||||||
|
|
|
@ -40,8 +40,8 @@ module JSON
|
||||||
# Convert a UTF8 encoded Ruby string _string_ to a JSON string, encoded with
|
# Convert a UTF8 encoded Ruby string _string_ to a JSON string, encoded with
|
||||||
# UTF16 big endian characters as \u????, and return it.
|
# UTF16 big endian characters as \u????, and return it.
|
||||||
def utf8_to_json(string) # :nodoc:
|
def utf8_to_json(string) # :nodoc:
|
||||||
string = string.gsub(/["\\\/\x0-\x1f]/) { MAP[$&] }
|
string = string.dup.force_encoding(Encoding::ASCII_8BIT)
|
||||||
string.force_encoding(Encoding::ASCII_8BIT)
|
string.gsub!(/["\\\/\x0-\x1f]/) { MAP[$&] }
|
||||||
string.gsub!(/(
|
string.gsub!(/(
|
||||||
(?:
|
(?:
|
||||||
[\xc2-\xdf][\x80-\xbf] |
|
[\xc2-\xdf][\x80-\xbf] |
|
||||||
|
|
Loading…
Add table
Reference in a new issue