c++ - ConvertUTF16toUCS4 in Apache Xerces -
the source code apache xerces: convertutf16toucs4 is:
conversionresult convertutf16toucs4( utf16 **sourcestart, utf16 *sourceend, ucs4 **targetstart, const ucs4 *targetend) { conversionresult result = ok; register utf16 *source = *sourcestart; register ucs4 *target = *targetstart; while (source < sourceend) { register ucs4 ch; ch = *source++; if (ch >= ksurrogatehighstart && ch <= ksurrogatehighend && source < sourceend) { register ucs4 ch2 = *source; if (ch2 >= ksurrogatelowstart && ch2 <= ksurrogatelowend) { ch = ((ch - ksurrogatehighstart) << halfshift) + (ch2 - ksurrogatelowstart) + halfbase; ++source; }; }; if (target >= targetend) { result = targetexhausted; break; }; *target++ = ch; }; *sourcestart = source; *targetstart = target; return result; };
i trying convert utf16 encoded surrogate pairs ucs4 encoded data. using windowsos , little endian machine.
if closely, can see that, after conversion, assigning target *targetstart
. wouldn't pointing last element of target instead of first element of target? when remove statement *targetstart = target;
code, working expected. bug in api or missing something?
Comments
Post a Comment