X-Git-Url: https://git.saurik.com/apple/icu.git/blobdiff_plain/f3c0d7a59d99c2a94c6b8822291f0e42be3773c9..a01113dcd0f39d5da295ef82785beff9ed86fe38:/icuSources/common/ucnvlat1.cpp?ds=sidebyside diff --git a/icuSources/common/ucnvlat1.cpp b/icuSources/common/ucnvlat1.cpp index 8aa5456b..358bc0ca 100644 --- a/icuSources/common/ucnvlat1.cpp +++ b/icuSources/common/ucnvlat1.cpp @@ -23,6 +23,7 @@ #include "unicode/utf8.h" #include "ucnv_bld.h" #include "ucnv_cnv.h" +#include "ustr_imp.h" /* control optimizations according to the platform */ #define LATIN1_UNROLL_FROM_UNICODE 1 @@ -339,7 +340,11 @@ ucnv_Latin1FromUTF8(UConverterFromUnicodeArgs *pFromUArgs, targetCapacity=(int32_t)(pFromUArgs->targetLimit-pFromUArgs->target); /* get the converter state from the UTF-8 UConverter */ - c=(UChar32)utf8->toUnicodeStatus; + if (utf8->toULength > 0) { + c=(UChar32)utf8->toUnicodeStatus; + } else { + c = 0; + } if(c!=0 && source0) { b=*source++; - if((int8_t)b>=0) { + if(U8_IS_SINGLE(b)) { /* convert ASCII */ *target++=(uint8_t)b; --targetCapacity; @@ -409,7 +414,7 @@ ucnv_Latin1FromUTF8(UConverterFromUnicodeArgs *pFromUArgs, if(U_SUCCESS(*pErrorCode) && source<(sourceLimit=(uint8_t *)pToUArgs->sourceLimit)) { utf8->toUnicodeStatus=utf8->toUBytes[0]=b=*source++; utf8->toULength=1; - utf8->mode=U8_COUNT_TRAIL_BYTES(b)+1; + utf8->mode=U8_COUNT_BYTES(b); } /* write back the updated pointers */ @@ -619,7 +624,7 @@ ucnv_ASCIIFromUTF8(UConverterFromUnicodeArgs *pFromUArgs, uint8_t c; - if(pToUArgs->converter->toUnicodeStatus!=0) { + if(pToUArgs->converter->toULength > 0) { /* no handling of partial UTF-8 characters here, fall back to pivoting */ *pErrorCode=U_USING_DEFAULT_WARNING; return;