From 9998481d4efaf86dde652617ed3b2777924c3373 Mon Sep 17 00:00:00 2001 From: duerst Date: Thu, 3 Dec 2009 11:29:33 +0000 Subject: [PATCH] * enc/trans/gb18030-tbl.rb: Fix omission of C1 region in code table (from Tatsuya Mizuno) * test/ruby/test_transcode.rb: Added test for converting full range of Unicode codepoints from/to GB18030 (from Tatsuya Mizuno) git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25980 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 8 ++++++++ enc/trans/gb18030-tbl.rb | 32 ++++++++++++++++++++++++++++++++ test/ruby/test_transcode.rb | 10 ++++++++-- 3 files changed, 48 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 02d08825234f3d..84da2a7b784d59 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Thu Dec 3 20:27:27 2009 Martin Duerst + + * enc/trans/gb18030-tbl.rb: Fix omission of C1 region in code table + (from Tatsuya Mizuno) + + * test/ruby/test_transcode.rb: Added test for converting full range of + Unicode codepoints from/to GB18030 (from Tatsuya Mizuno) + Wed Dec 2 23:51:28 2009 NAKAMURA, Hiroshi * ext/openssl/ossl_ssl.c: initialize @hostname of SSLSocket to avoid diff --git a/enc/trans/gb18030-tbl.rb b/enc/trans/gb18030-tbl.rb index 17a01d8885825b..e1c29deeb1f5aa 100644 --- a/enc/trans/gb18030-tbl.rb +++ b/enc/trans/gb18030-tbl.rb @@ -1,4 +1,36 @@ GB18030_TO_UCS_TBL = [ + ["81308130",0x80], + ["81308131",0x81], + ["81308132",0x82], + ["81308133",0x83], + ["81308134",0x84], + ["81308135",0x85], + ["81308136",0x86], + ["81308137",0x87], + ["81308138",0x88], + ["81308139",0x89], + ["81308230",0x8A], + ["81308231",0x8B], + ["81308232",0x8C], + ["81308233",0x8D], + ["81308234",0x8E], + ["81308235",0x8F], + ["81308236",0x90], + ["81308237",0x91], + ["81308238",0x92], + ["81308239",0x93], + ["81308330",0x94], + ["81308331",0x95], + ["81308332",0x96], + ["81308333",0x97], + ["81308334",0x98], + ["81308335",0x99], + ["81308336",0x9A], + ["81308337",0x9B], + ["81308338",0x9C], + ["81308339",0x9D], + ["81308430",0x9E], + ["81308431",0x9F], ["81308432",0xA0], ["81308433",0xA1], ["81308434",0xA2], diff --git a/test/ruby/test_transcode.rb b/test/ruby/test_transcode.rb index 2cc23bae8fc673..bec153b491cd2c 100644 --- a/test/ruby/test_transcode.rb +++ b/test/ruby/test_transcode.rb @@ -1578,7 +1578,13 @@ def test_gbk end def test_gb18030 - # test from GBK + # overall roundtrip test + all_gb18030 = (0x0..0xD7FF).to_a.pack 'U*' #追加 + all_gb18030 << (0xE000..0xFFFF).to_a.pack("U*") #追加 + + assert_equal(all_gb18030, all_gb18030.encode("gb18030").encode("UTF-8")) #追加 + + # tests from GBK check_both_ways("\u4E02", "\x81\x40", 'GB18030') # check_both_ways("\u4E8A", "\x81\x7E", 'GB18030') # check_both_ways("\u4E90", "\x81\x80", 'GB18030') # @@ -1691,7 +1697,7 @@ def test_gb18030 check_both_ways("\u9752\u5C71\u5B66\u9662\u5927\u5B66", "\xC7\xE0\xC9\xBD\xD1\xA7\xD4\xBA\xB4\xF3\xD1\xA7", 'GB18030') # 青山学院大学 check_both_ways("\u795E\u6797\u7FA9\u535A", "\xC9\xF1\xC1\xD6\xC1\x78\xB2\xA9", 'GB18030') # 神林義 - # new tests for GB18030 + # new tests for GB18030 check_both_ways("\u9FA6", "\x82\x35\x8F\x33", 'GB18030') # 龦 check_both_ways("\uD7FF", "\x83\x36\xC7\x38", 'GB18030') # No name ()