mirror of
https://github.com/ruby/ruby.git
synced 2025-09-18 18:13:58 +02:00
* include/ruby/encoding.h (ECONV_UNDEF_HEX_CHARREF): defined.
* transcode.c (output_hex_charref): new function. (rb_econv_convert): call output_hex_charref if ECONV_UNDEF_HEX_CHARREF. (Init_transcode): Encoding::Converter::UNDEF_HEX_CHARREF added. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19162 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
7d3598ee60
commit
c500c37fbc
4 changed files with 94 additions and 0 deletions
|
@ -670,4 +670,19 @@ class TestEncodingConverter < Test::Unit::TestCase
|
|||
ec = Encoding::Converter.new("utf-8", "us-ascii", :undef => :replace, :replace => "X")
|
||||
assert_equal("a X b", ec.convert("a \u3042 b"))
|
||||
end
|
||||
|
||||
def test_hex_charref
|
||||
ec = Encoding::Converter.new("UTF-8", "US-ASCII", Encoding::Converter::UNDEF_HEX_CHARREF)
|
||||
assert_equal("あ", ec.convert("\u3042"))
|
||||
|
||||
ec = Encoding::Converter.new("UTF-8", "EUC-JP", Encoding::Converter::UNDEF_HEX_CHARREF)
|
||||
assert_equal("\xa4\xcf\xa4\xa1\xa4\xa4♥\xa1\xa3".force_encoding("euc-jp"),
|
||||
ec.convert("\u{306f 3041 3044 2665 3002}"))
|
||||
|
||||
ec = Encoding::Converter.new("UTF-8", "ISO-2022-JP", Encoding::Converter::UNDEF_HEX_CHARREF)
|
||||
assert_equal("\e$B$O$!$$\e(B♥\e$B!#".force_encoding("ISO-2022-JP"),
|
||||
ec.convert("\u{306f 3041 3044 2665 3002}"))
|
||||
assert_equal("\e(B".force_encoding("ISO-2022-JP"),
|
||||
ec.finish)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue