[前][次][番号順一覧][スレッド一覧]

ruby-changes:5221

From: naruse <ko1@a...>
Date: Sat, 31 May 2008 19:14:55 +0900 (JST)
Subject: [ruby-changes:5221] Ruby:r16717 (trunk): * enc/utf_16{be,le}.c (utf16{be,le}_code_to_mbc):

naruse	2008-05-31 19:14:38 +0900 (Sat, 31 May 2008)

  New Revision: 16717

  Modified files:
    trunk/ChangeLog
    trunk/enc/utf_16be.c
    trunk/enc/utf_16le.c

  Log:
    * enc/utf_16{be,le}.c (utf16{be,le}_code_to_mbc):
      fix codepoint to bytes.

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=16717&r2=16716&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/enc/utf_16le.c?r1=16717&r2=16716&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/enc/utf_16be.c?r1=16717&r2=16716&diff_format=u

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 16716)
+++ ChangeLog	(revision 16717)
@@ -1,3 +1,8 @@
+Sat May 31 19:11:39 2008  NARUSE, Yui  <naruse@r...>
+
+	* 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@r...>
 
 	* suppress warnings with -Wwrite-string.
Index: enc/utf_16be.c
===================================================================
--- enc/utf_16be.c	(revision 16716)
+++ enc/utf_16be.c	(revision 16717)
@@ -132,14 +132,12 @@
   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 {
Index: enc/utf_16le.c
===================================================================
--- enc/utf_16le.c	(revision 16716)
+++ enc/utf_16le.c	(revision 16717)
@@ -126,15 +126,12 @@
   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 {

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]