mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* string.c (rb_str_inspect): fix typo (not 0xFD but 0xFE).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29989 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
54fd6de064
commit
ed22b0ecee
3 changed files with 16 additions and 1 deletions
|
@ -1,3 +1,7 @@
|
||||||
|
Wed Dec 1 10:16:41 2010 NARUSE, Yui <naruse@ruby-lang.org>
|
||||||
|
|
||||||
|
* string.c (rb_str_inspect): fix typo (not 0xFD but 0xFE).
|
||||||
|
|
||||||
Wed Dec 1 09:28:27 2010 NARUSE, Yui <naruse@ruby-lang.org>
|
Wed Dec 1 09:28:27 2010 NARUSE, Yui <naruse@ruby-lang.org>
|
||||||
|
|
||||||
* addr2line.c: Follow .gnu_debuglink section.
|
* addr2line.c: Follow .gnu_debuglink section.
|
||||||
|
|
2
string.c
2
string.c
|
@ -4217,7 +4217,7 @@ rb_str_inspect(VALUE str)
|
||||||
const unsigned char *q = (const unsigned char *)p;
|
const unsigned char *q = (const unsigned char *)p;
|
||||||
if (q[0] == 0xFE && q[1] == 0xFF)
|
if (q[0] == 0xFE && q[1] == 0xFF)
|
||||||
enc = rb_enc_find("UTF-16BE");
|
enc = rb_enc_find("UTF-16BE");
|
||||||
else if (q[0] == 0xFF && q[1] == 0xFD)
|
else if (q[0] == 0xFF && q[1] == 0xFE)
|
||||||
enc = rb_enc_find("UTF-16LE");
|
enc = rb_enc_find("UTF-16LE");
|
||||||
else
|
else
|
||||||
unicode_p = 0;
|
unicode_p = 0;
|
||||||
|
|
|
@ -243,6 +243,17 @@ class TestM17N < Test::Unit::TestCase
|
||||||
s.dup.force_encoding(enc).inspect)
|
s.dup.force_encoding(enc).inspect)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
str = "\uFEFF\u3042"
|
||||||
|
%w/UTF-16 UTF-32/.each do |enc|
|
||||||
|
%w/BE LE/.each do |endian|
|
||||||
|
s = str.encode(enc + endian)
|
||||||
|
# When a UTF-16/32 string doesn't have a BOM,
|
||||||
|
# inspect as a dummy encoding string.
|
||||||
|
assert_equal(s.inspect,
|
||||||
|
s.dup.force_encoding(enc).inspect)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_str_dump
|
def test_str_dump
|
||||||
|
|
Loading…
Add table
Reference in a new issue