| Issue 62: | UTF8 Encoding | |
| 1 person starred this issue and may be notified of changes. | Back to list |
I found a pair of small bugs in ConvertToUTF8 and UTF8EncodeAdvance when I noticed the name property of NME DisplayObjects always ended up as a string of null bytes. This is with hxcpp r243, nme r512, haxe r3358. UTF8EncodeAdvance didn't actually advance the pointer for characters that have one byte utf-8 representations. In ConvertToUTF8, I'm thinking it should allocate 'chars + 1' rather than 'len + 1' bytes to accommodate the utf-8 encoding. Thanks for the great code, Adam Index: src/String.cpp =================================================================== --- src/String.cpp (revision 243) +++ src/String.cpp (working copy) @@ -391,7 +391,7 @@ void UTF8EncodeAdvance(char * &ioPtr,int c) { if( c <= 0x7F ) - *ioPtr = (c); + *ioPtr++ = (c); else if( c <= 0x7FF ) { *ioPtr++ = ( 0xC0 | (c >> 6) ); @@ -585,8 +585,8 @@ for(int i=0;i<len;i++) chars += UTF8Bytes(inStr[i]); } - - char *buf = (char *)NewGCPrivate(0,len+1); + + char *buf = (char *)NewGCPrivate(0,chars+1); char *ptr = buf; for(int i=0;i<len;i++) UTF8EncodeAdvance(ptr,
Sep 10, 2010
Project Member
#1
gameh...@gmail.com
Status:
Fixed
|