[Mono-bugs] [Bug 79888][Cri] New - [libgdiplus] utf8_to_ucs2() makes wrong code with the value over 0x1000
bugzilla-daemon at bugzilla.ximian.com
bugzilla-daemon at bugzilla.ximian.com
Fri Nov 10 02:33:53 EST 2006
Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.
Changed by choe.hwanjin at gmail.com.
http://bugzilla.ximian.com/show_bug.cgi?id=79888
--- shadow/79888 2006-11-10 02:33:53.000000000 -0500
+++ shadow/79888.tmp.2314 2006-11-10 02:33:53.000000000 -0500
@@ -0,0 +1,63 @@
+Bug#: 79888
+Product: Mono: Class Libraries
+Version: 1.1
+OS:
+OS Details:
+Status: NEW
+Resolution:
+Severity:
+Priority: Critical
+Component: libgdiplus
+AssignedTo: mono-bugs at ximian.com
+ReportedBy: choe.hwanjin at gmail.com
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL:
+Cc:
+Summary: [libgdiplus] utf8_to_ucs2() makes wrong code with the value over 0x1000
+
+Description of Problem:
+
+I'm using libgdiplus-1.1.18.
+The function utf8_to_ucs2() in src/general.c makes wrong code value when
+the character code is over 0x1000.
+Because there is a typo on the expression which check the code value.
+It compares the ucs4 code with 0x1000 not 0x10000.
+
+general.c:495
+ ptr = (gunichar2 *)ucs2;
+ for (i = 0; (i < count) && (i < ucs2_len); i++) {
+ if (ucs4[i] < 0x1000 && !(ucs4[i] >= 0xd800 && ucs4[i] < 0xe000)) {
+ ^^^^^^^
+ +---> this should be 0x10000
+ *ptr = (gunichar2)ucs4[i];
+ ptr++;
+ } /* we're simply ignoring any chars that don't fit into ucs2 */
+ }
+ ucs2[i] = 0; /* terminate */
+
+So when I call GdipGetFamilyName(), then it calls utf8_to_ucs2(). But
+it does not make correct ucs2 code when the font name has some characters
+which has the value over 0x1000, ie, localized family name.
+
+But the real problem is that the WCHAR string is not UCS2 string. It is
+UTF-16 encoded string.
+So you can use g_utf8_to_utf16() and g_utf16_to_utf8() to convert
+between UTF-8 string and WCHAR string.
+
+I made a patch for that, see below:
+
+--- general.c.orig 2006-10-12 08:54:45.000000000 +0900
++++ general.c 2006-11-10 14:55:44.981491752 +0900
+@@ -494,7 +494,7 @@
+
+ ptr = (gunichar2 *)ucs2;
+ for (i = 0; (i < count) && (i < ucs2_len); i++) {
+- if (ucs4[i] < 0x1000 && !(ucs4[i] >= 0xd800 && ucs4[i] <
+0xe000)) {
++ if (ucs4[i] < 0x10000 && !(ucs4[i] >= 0xd800 && ucs4[i] <
+0xe000)) {
+ *ptr = (gunichar2)ucs4[i];
+ ptr++;
+ } /* we're simply ignoring any chars that don't fit
+into ucs2 */
More information about the mono-bugs
mailing list