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

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -