summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--enc/trans/iso2022.trans19
-rw-r--r--test/ruby/test_transcode.rb18
3 files changed, 34 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index 2a3b3c9c73..2ae023d6d4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Thu Apr 1 17:17:00 2010 NARUSE, Yui <naruse@ruby-lang.org>
+
+ * enc/trans/iso2022.trans: CP50221 supports 8bit JIS.
+
Thu Apr 1 16:44:00 2010 Eric Hodel <drbrain@segment7.net>
* lib/rdoc, test/rdoc: Imported RDoc 2.5
diff --git a/enc/trans/iso2022.trans b/enc/trans/iso2022.trans
index a93f211f62..0acb7b22d3 100644
--- a/enc/trans/iso2022.trans
+++ b/enc/trans/iso2022.trans
@@ -46,7 +46,7 @@
"1b2442" => :func_so, # designate JIS X 0208 1983 to G0. "ESC $ B"
"0e" => :func_so, # designate JIS X 0201 katakana to G0. "SO"
"0f" => :func_so, # designate US-ASCII to G0. "SI"
- "{00-0d,10-1a,1c-92}" => :func_si,
+ "{00-0d,10-1a,1c-92,a1-df}" => :func_si,
}
transcode_generate_node(ActionMap.parse(map), "cp50221_decoder")
@@ -269,22 +269,26 @@ static VALUE
fun_si_cp50221_decoder(void *statep, const unsigned char *s, size_t l)
{
unsigned char *sp = statep;
+ int c;
switch (*sp) {
case G0_ASCII:
+ if (0xA1 <= s[0] && s[0] <= 0xDF)
+ return (VALUE)FUNso;
return (VALUE)NOMAP;
case G0_JISX0201_KATAKANA:
- if (0x21 <= s[0] && s[0] <= 0x5f)
+ c = s[0] & 0x7F;
+ if (0x21 <= c && c <= 0x5f)
return (VALUE)FUNso;
break;
case G0_JISX0208_1978:
- if (0x21 <= s[0] && s[0] <= 0x28 || 0x30 <= s[0] && s[0] <= 0x74)
+ if ((0x21 <= s[0] && s[0] <= 0x28) || (0x30 <= s[0] && s[0] <= 0x74))
return (VALUE)iso2022jp_decoder_jisx0208_rest;
break;
case G0_JISX0208_1983:
- if (0x21 <= s[0] && s[0] <= 0x28 ||
+ if ((0x21 <= s[0] && s[0] <= 0x28) ||
s[0] == 0x2D ||
- 0x30 <= s[0] && s[0] <= 0x74 ||
- 0x79 <= s[0] && s[0] <= 0x7C)
+ (0x30 <= s[0] && s[0] <= 0x74) ||
+ (0x79 <= s[0] && s[0] <= 0x7C))
/* 0x7F <= s[0] && s[0] <= 0x92) */
return (VALUE)iso2022jp_decoder_jisx0208_rest;
break;
@@ -327,7 +331,8 @@ fun_so_cp50221_decoder(void *statep, const unsigned char *s, size_t l, unsigned
*sp = G0_ASCII;
return 0;
default:
- if (*sp == G0_JISX0201_KATAKANA) {
+ if (*sp == G0_JISX0201_KATAKANA ||
+ (0xA1 <= s[0] && s[0] <= 0xDF && *sp == G0_ASCII)) {
o[0] = 0x8E;
o[1] = s[0] | 0x80;
}
diff --git a/test/ruby/test_transcode.rb b/test/ruby/test_transcode.rb
index bca51ba251..7f73d31797 100644
--- a/test/ruby/test_transcode.rb
+++ b/test/ruby/test_transcode.rb
@@ -1357,6 +1357,24 @@ class TestTranscode < Test::Unit::TestCase
"\xA1\xA1".encode("ISO-2022-JP", "EUC-JP"))
end
+ def test_cp50221
+ assert_equal("!", "\e(B\x21".encode("utf-8", "cp50221"))
+ assert_equal("!", "\e(J\x21".encode("utf-8", "cp50221"))
+ assert_equal("\uFF71", "\xB1".encode("utf-8", "cp50221"))
+ assert_equal("\uFF71", "\e(B\xB1".encode("utf-8", "cp50221"))
+ assert_equal("\uFF71", "\e(J\xB1".encode("utf-8", "cp50221"))
+ assert_equal("\uFF71", "\e(I\xB1".encode("utf-8", "cp50221"))
+ assert_equal("\uFF71", "\e(I\x31".encode("utf-8", "cp50221"))
+ assert_equal("\uFF71", "\x0E\xB1".encode("utf-8", "cp50221"))
+ assert_equal("\u3000", "\e$@\x21\x21".encode("utf-8", "cp50221"))
+ assert_equal("\u3000", "\e$B\x21\x21".encode("utf-8", "cp50221"))
+ assert_equal("\u2460", "\e$B\x2D\x21".encode("utf-8", "cp50221"))
+ assert_equal("\u7e8a", "\e$B\x79\x21".encode("utf-8", "cp50221"))
+ assert_equal("\u5fde", "\e$B\x7A\x21".encode("utf-8", "cp50221"))
+ assert_equal("\u72be", "\e$B\x7B\x21".encode("utf-8", "cp50221"))
+ assert_equal("\u91d7", "\e$B\x7C\x21".encode("utf-8", "cp50221"))
+ end
+
def test_iso_2022_jp_1
# check_both_ways("\u9299", "\x1b$(Dd!\x1b(B", "iso-2022-jp-1") # JIS X 0212 区68 点01 銙
end