summaryrefslogtreecommitdiff
path: root/sal/textenc/convertiso2022kr.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'sal/textenc/convertiso2022kr.cxx')
-rw-r--r--sal/textenc/convertiso2022kr.cxx17
1 files changed, 15 insertions, 2 deletions
diff --git a/sal/textenc/convertiso2022kr.cxx b/sal/textenc/convertiso2022kr.cxx
index c65bc8597414..6169969812d2 100644
--- a/sal/textenc/convertiso2022kr.cxx
+++ b/sal/textenc/convertiso2022kr.cxx
@@ -100,6 +100,7 @@ sal_Size ImplConvertIso2022KrToUnicode(void const * pData,
sal_Size nConverted = 0;
sal_Unicode * pDestBufPtr = pDestBuf;
sal_Unicode * pDestBufEnd = pDestBuf + nDestChars;
+ sal_Size startOfCurrentChar = 0;
if (pContext)
{
@@ -119,9 +120,10 @@ sal_Size ImplConvertIso2022KrToUnicode(void const * pData,
else if (nChar == 0x1B) // ESC
eState = IMPL_ISO_2022_KR_TO_UNICODE_STATE_ESC;
else if (nChar < 0x80)
- if (pDestBufPtr != pDestBufEnd)
+ if (pDestBufPtr != pDestBufEnd) {
*pDestBufPtr++ = static_cast<sal_Unicode>(nChar);
- else
+ startOfCurrentChar = nConverted + 1;
+ } else
goto no_output;
else
{
@@ -159,6 +161,7 @@ sal_Size ImplConvertIso2022KrToUnicode(void const * pData,
{
*pDestBufPtr++ = static_cast<sal_Unicode>(nUnicode);
eState = IMPL_ISO_2022_KR_TO_UNICODE_STATE_1001;
+ startOfCurrentChar = nConverted + 1;
}
else
goto no_output;
@@ -211,10 +214,16 @@ sal_Size ImplConvertIso2022KrToUnicode(void const * pData,
{
case sal::detail::textenc::BAD_INPUT_STOP:
eState = IMPL_ISO_2022_KR_TO_UNICODE_STATE_ASCII;
+ if ((nFlags & RTL_TEXTTOUNICODE_FLAGS_FLUSH) == 0) {
+ ++nConverted;
+ } else {
+ nConverted = startOfCurrentChar;
+ }
break;
case sal::detail::textenc::BAD_INPUT_CONTINUE:
eState = IMPL_ISO_2022_KR_TO_UNICODE_STATE_ASCII;
+ startOfCurrentChar = nConverted + 1;
continue;
case sal::detail::textenc::BAD_INPUT_NO_OUTPUT:
@@ -241,6 +250,10 @@ sal_Size ImplConvertIso2022KrToUnicode(void const * pData,
&nInfo))
{
case sal::detail::textenc::BAD_INPUT_STOP:
+ if ((nFlags & RTL_TEXTTOUNICODE_FLAGS_FLUSH) != 0) {
+ nConverted = startOfCurrentChar;
+ }
+ [[fallthrough]];
case sal::detail::textenc::BAD_INPUT_CONTINUE:
eState = IMPL_ISO_2022_KR_TO_UNICODE_STATE_ASCII;
break;