Author: atsushi
Date: 2005-04-23 14:38:25 -0400 (Sat, 23 Apr 2005)
New Revision: 43501
Modified:
trunk/mcs/class/I18N/CJK/CP51932.cs
Log:
2005-04-23 Atsushi Enomoto <[EMAIL PROTECTED]>
* CP51932.cs : Fixed GetCharCount() that did not match with GetChars().
Modified: trunk/mcs/class/I18N/CJK/CP51932.cs
===================================================================
--- trunk/mcs/class/I18N/CJK/CP51932.cs 2005-04-23 18:37:15 UTC (rev 43500)
+++ trunk/mcs/class/I18N/CJK/CP51932.cs 2005-04-23 18:38:25 UTC (rev 43501)
@@ -253,32 +253,42 @@
// Determine the total length of the converted string.
int length = 0;
int byteval;
+ int last = 0;
+
while (count > 0) {
byteval = bytes [index++];
--count;
- ++length;
- if (byteval < 0x80) {
- // Ordinary ASCII/Latin1 character, or the
- // single-byte Yen or overline signs.
- continue;
- }
- else if (byteval == 0xFF) {
- if (count >= 2) {
- count -= 2;
+ if (last == 0) {
+ if (byteval == 0x8F) {
+ if (byteval != 0) {
+ // Invalid second byte of a
3-byte character
+ // FIXME: What should we do?
+ last = 0;
+ }
+ // First byte in a triple-byte sequence
+ else
+ last = byteval;
+ } else if (byteval <= 0x7F) {
+ // Ordinary ASCII/Latin1/Control
character.
++length;
+ } else if (byteval >= 0xA1 && byteval <= 0xFE) {
+ // First byte in a double-byte sequence.
+ last = byteval;
} else {
- count--;
- ++length; // "??" for invalid 3-byte
character
+ // Invalid first byte. Let '?'
+ ++length;
}
- continue;
+ } else if (last == 0x8F) {
+ // 3-byte character
+ // FIXME: currently not supported yet
+ lastByte = 0;
+ ++length;
+ } else {
+ // Second byte in a double-byte sequence.
+ lastByte = 0;
+ ++length;
}
- if(count == 0) {
- // Missing second byte.
- continue;
- }
- ++index;
- --count;
}
// Return the total length.
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches