From 766f81657536fd629dc02dc34c489209c6db2a2e Mon Sep 17 00:00:00 2001 From: Ethan Date: Wed, 20 Oct 2021 13:53:18 -0700 Subject: fix parsing of unicode, mixing literal characters with escaped, by forcing encoding back to ASCII_8BIT before gsubing back into parse_string result --- lib/json/pure/parser.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/json/pure/parser.rb b/lib/json/pure/parser.rb index e1d701b..be48c60 100644 --- a/lib/json/pure/parser.rb +++ b/lib/json/pure/parser.rb @@ -179,7 +179,7 @@ module JSON bytes << c[6 * i + 2, 2].to_i(16) << c[6 * i + 4, 2].to_i(16) i += 1 end - JSON.iconv('utf-8', 'utf-16be', bytes) + JSON.iconv('utf-8', 'utf-16be', bytes).force_encoding(::Encoding::ASCII_8BIT) end end if string.respond_to?(:force_encoding) -- cgit v1.2.1