Sha256: 1b341746123a5012330045e0b5536876fc8c028a113ac5d1081cf2e4cd0fa782
Contents?: true
Size: 1.54 KB
Versions: 1
Compression:
Stored size: 1.54 KB
Contents
require 'rubygems' require 'spec' dir = File.dirname(__FILE__) require File.expand_path("#{dir}/spec_helper") require File.expand_path("#{dir}/../lib/fjson") context "String with UTF8 values when supporting unicode Json" do setup do JSON.support_unicode = true $KCODE = "UTF8" end specify "should format values between 0x00000080 and 0x000007ff" do val = [0x0080].pack("U") JSON.utf8_to_json(val).should_eql "\\u0080" val = [0x07ff].pack("U") JSON.utf8_to_json(val).should_eql "\\u07ff" end specify "should format values between 0x00001000 and 0x0000ffff" do val = [0x1000].pack("U") JSON.utf8_to_json(val).should_eql "\\u1000" val = [0xffff].pack("U") JSON.utf8_to_json(val).should_eql "\\uffff" end specify "should format values between 0x00010000 and 0x0010ffff" do val = [0x010000].pack("U") JSON.utf8_to_json(val).should_eql "\\ud800dc00" val = [0x10ffff].pack("U") JSON.utf8_to_json(val).should_eql "\\udbffdfff" end specify "should parse unicode values" do utf8 = '© ≠ €!' json = '"\u00a9 \u2260 \u20ac!"' utf8.to_json.should_eql json JSON.parse(json).should_eql utf8 utf8 = "\343\201\202\343\201\204\343\201\206\343\201\210\343\201\212" json = '"\u3042\u3044\u3046\u3048\u304a"' utf8.to_json.should_eql json JSON.parse(json).should_eql utf8 utf8 = 'საქართველო' json = '"\u10e1\u10d0\u10e5\u10d0\u10e0\u10d7\u10d5\u10d4\u10da\u10dd"' utf8.to_json.should_eql json JSON.parse(json).should_eql utf8 end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
fjson-0.1.1 | spec/string_with_utf8_values_when_supporting_unicode_json_spec.rb |