mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* enc/utf_16{be,le}.c (utf16{be,le}_code_to_mbc):
fix codepoint to bytes. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16717 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
075530a685
commit
0682fab6a2
3 changed files with 17 additions and 17 deletions
|
@ -1,3 +1,8 @@
|
|||
Sat May 31 19:11:39 2008 NARUSE, Yui <naruse@ruby-lang.org>
|
||||
|
||||
* enc/utf_16{be,le}.c (utf16{be,le}_code_to_mbc):
|
||||
fix codepoint to bytes.
|
||||
|
||||
Sat May 31 18:28:17 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* suppress warnings with -Wwrite-string.
|
||||
|
|
|
@ -132,14 +132,12 @@ utf16be_code_to_mbc(OnigCodePoint code, UChar *buf,
|
|||
UChar* p = buf;
|
||||
|
||||
if (code > 0xffff) {
|
||||
unsigned int plane, high;
|
||||
|
||||
plane = code >> 16;
|
||||
*p++ = (plane >> 2) + 0xd8;
|
||||
high = (code & 0xff00) >> 8;
|
||||
*p++ = ((plane & 0x03) << 6) + (high >> 2);
|
||||
*p++ = (high & 0x02) + 0xdc;
|
||||
*p = (UChar )(code & 0xff);
|
||||
unsigned int high = (code >> 10) + 0xD7C0;
|
||||
unsigned int low = (code & 0x3FF) + 0xDC00;
|
||||
*p++ = (high >> 8) & 0xFF;
|
||||
*p++ = high & 0xFF;
|
||||
*p++ = (low >> 8) & 0xFF;
|
||||
*p++ = low & 0xFF;
|
||||
return 4;
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -126,15 +126,12 @@ utf16le_code_to_mbc(OnigCodePoint code, UChar *buf,
|
|||
UChar* p = buf;
|
||||
|
||||
if (code > 0xffff) {
|
||||
unsigned int plane, high;
|
||||
|
||||
plane = code >> 16;
|
||||
high = (code & 0xff00) >> 8;
|
||||
|
||||
*p++ = ((plane & 0x03) << 6) + (high >> 2);
|
||||
*p++ = (plane >> 2) + 0xd8;
|
||||
*p++ = (UChar )(code & 0xff);
|
||||
*p = (high & 0x02) + 0xdc;
|
||||
unsigned int high = (code >> 10) + 0xD7C0;
|
||||
unsigned int low = (code & 0x3FF) + 0xDC00;
|
||||
*p++ = high & 0xFF;
|
||||
*p++ = (high >> 8) & 0xFF;
|
||||
*p++ = low & 0xFF;
|
||||
*p++ = (low >> 8) & 0xFF;
|
||||
return 4;
|
||||
}
|
||||
else {
|
||||
|
|
Loading…
Reference in a new issue