summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-09-05 20:37:36 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-09-05 20:37:36 +0000
commitdc98e2528a3d553a6ea7028482df8d5c48582601 (patch)
tree548030c76f94360d5548046d809f3437d75aec76
parentc500c37fbc3950e5511d5864da075b17f15a58cc (diff)
downloadruby-dc98e2528a3d553a6ea7028482df8d5c48582601.tar.gz
* transcode.c (output_hex_charref): upcase hexadecimal digits.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19163 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog4
-rw-r--r--test/ruby/test_econv.rb8
-rw-r--r--transcode.c2
3 files changed, 13 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 0926dfba14..db356deb1c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Sat Sep 6 05:37:08 2008 Tanaka Akira <akr@fsij.org>
+
+ * transcode.c (output_hex_charref): upcase hexadecimal digits.
+
Sat Sep 6 05:22:29 2008 Tanaka Akira <akr@fsij.org>
* include/ruby/encoding.h (ECONV_UNDEF_HEX_CHARREF): defined.
diff --git a/test/ruby/test_econv.rb b/test/ruby/test_econv.rb
index 29ae65b5a7..0a774c4a7a 100644
--- a/test/ruby/test_econv.rb
+++ b/test/ruby/test_econv.rb
@@ -684,5 +684,13 @@ class TestEncodingConverter < Test::Unit::TestCase
ec.convert("\u{306f 3041 3044 2665 3002}"))
assert_equal("\e(B".force_encoding("ISO-2022-JP"),
ec.finish)
+
+ ec = Encoding::Converter.new("EUC-JP", "US-ASCII", Encoding::Converter::UNDEF_HEX_CHARREF)
+ assert_equal("&#x4EA4;&#x63DB;&#x6CD5;&#x5247;: n&#xD7;m=m&#xD7;n".force_encoding("ISO-8859-1"),
+ ec.convert("\xB8\xF2\xB4\xB9\xCB\xA1\xC2\xA7: n\xA1\xDFm=m\xA1\xDFn"))
+
+ ec = Encoding::Converter.new("EUC-JP", "ISO-8859-1", Encoding::Converter::UNDEF_HEX_CHARREF)
+ assert_equal("&#x4EA4;&#x63DB;&#x6CD5;&#x5247;: n\xD7m=m\xD7n".force_encoding("ISO-8859-1"),
+ ec.convert("\xB8\xF2\xB4\xB9\xCB\xA1\xC2\xA7: n\xA1\xDFm=m\xA1\xDFn"))
end
end
diff --git a/transcode.c b/transcode.c
index 5318c564e3..6496c75c76 100644
--- a/transcode.c
+++ b/transcode.c
@@ -1303,7 +1303,7 @@ output_hex_charref(rb_econv_t *ec)
u += p[1] << 16;
u += p[2] << 8;
u += p[3];
- snprintf(charef_buf, sizeof(charef_buf), "&#x%x;", u);
+ snprintf(charef_buf, sizeof(charef_buf), "&#x%X;", u);
ret = rb_econv_insert_output(ec, (unsigned char *)charef_buf, strlen(charef_buf), "US-ASCII");
if (ret == -1)