mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* string.c (rb_str_inspect): treat UTF-16 and UTF-32 as BE or LE.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29896 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
38b482be8c
commit
220d07d2fc
2 changed files with 13 additions and 0 deletions
|
@ -1,3 +1,7 @@
|
|||
Wed Nov 24 11:19:13 2010 NARUSE, Yui <naruse@ruby-lang.org>
|
||||
|
||||
* string.c (rb_str_inspect): treat UTF-16 and UTF-32 as BE or LE.
|
||||
|
||||
Wed Nov 24 06:35:32 2010 NARUSE, Yui <naruse@ruby-lang.org>
|
||||
|
||||
* enc/trans/utf_16_32.trans: add the UTF-32 converter.
|
||||
|
|
9
string.c
9
string.c
|
@ -4202,7 +4202,10 @@ rb_str_inspect(VALUE str)
|
|||
rb_encoding *resenc = rb_default_internal_encoding();
|
||||
int unicode_p = rb_enc_unicode_p(enc);
|
||||
int asciicompat = rb_enc_asciicompat(enc);
|
||||
static rb_encoding *utf16, *utf32;
|
||||
|
||||
if (!utf16) utf16 = rb_enc_find("UTF-16");
|
||||
if (!utf32) utf32 = rb_enc_find("UTF-32");
|
||||
if (resenc == NULL) resenc = rb_default_external_encoding();
|
||||
if (!rb_enc_asciicompat(resenc)) resenc = rb_usascii_encoding();
|
||||
rb_enc_associate(result, resenc);
|
||||
|
@ -4210,6 +4213,12 @@ rb_str_inspect(VALUE str)
|
|||
|
||||
p = RSTRING_PTR(str); pend = RSTRING_END(str);
|
||||
prev = p;
|
||||
if (enc == utf16) {
|
||||
enc = *p == (char)0xFF ? rb_enc_find("UTF-16LE") : rb_enc_find("UTF-16BE");
|
||||
}
|
||||
else if (enc == utf32) {
|
||||
enc = *p == (char)0xFF ? rb_enc_find("UTF-32LE") : rb_enc_find("UTF-32BE");
|
||||
}
|
||||
while (p < pend) {
|
||||
unsigned int c, cc;
|
||||
int n;
|
||||
|
|
Loading…
Add table
Reference in a new issue