summaryrefslogtreecommitdiff
path: root/ext/json/lib/json/pure/generator.rb
diff options
context:
space:
mode:
Diffstat (limited to 'ext/json/lib/json/pure/generator.rb')
-rw-r--r--ext/json/lib/json/pure/generator.rb5
1 files changed, 3 insertions, 2 deletions
diff --git a/ext/json/lib/json/pure/generator.rb b/ext/json/lib/json/pure/generator.rb
index abc24bf72d7..9c7cfac0a2b 100644
--- a/ext/json/lib/json/pure/generator.rb
+++ b/ext/json/lib/json/pure/generator.rb
@@ -51,8 +51,9 @@ module JSON
[\x80-\xc1\xf5-\xff] # invalid
)/nx) { |c|
c.size == 1 and raise GeneratorError, "invalid utf8 byte: '#{c}'"
- c = c.unpack("U*")[0]
- c > 0xFFFF ? ('\ud%03x\ud%03x' % [0x7C0+c/1024, 0xC00+c%1024]) : ('\u%04x'%c)
+ c.unpack("U*").map{|c|
+ c>0xFFFF ? ('\ud%03x\ud%03x'%[0x7C0+c/1024,0xC00+c%1024]) : ('\u%04x'%c)
+ }.join("")
}
string
end