1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <sal/config.h>
22 #include <rtl/textcvt.h>
23 #include <sal/types.h>
25 #include "converter.hxx"
26 #include "convertiso2022cn.hxx"
27 #include "tenchelp.hxx"
28 #include "unichars.hxx"
32 enum ImplIso2022CnToUnicodeState
// order is important:
34 IMPL_ISO_2022_CN_TO_UNICODE_STATE_ASCII
,
35 IMPL_ISO_2022_CN_TO_UNICODE_STATE_SO
,
36 IMPL_ISO_2022_CN_TO_UNICODE_STATE_SO_2
,
37 IMPL_ISO_2022_CN_TO_UNICODE_STATE_116432
,
38 IMPL_ISO_2022_CN_TO_UNICODE_STATE_116432_2
,
39 IMPL_ISO_2022_CN_TO_UNICODE_STATE_ESC
,
40 IMPL_ISO_2022_CN_TO_UNICODE_STATE_ESC_DOLLAR
,
41 IMPL_ISO_2022_CN_TO_UNICODE_STATE_ESC_DOLLAR_RPAREN
,
42 IMPL_ISO_2022_CN_TO_UNICODE_STATE_ESC_DOLLAR_ASTERISK
45 struct ImplIso2022CnToUnicodeContext
47 ImplIso2022CnToUnicodeState m_eState
;
53 enum ImplUnicodeToIso2022CnDesignator
55 IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_NONE
,
56 IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_2312
,
57 IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_116431
60 struct ImplUnicodeToIso2022CnContext
62 sal_Unicode m_nHighSurrogate
;
63 ImplUnicodeToIso2022CnDesignator m_eSoDesignator
;
64 bool m_b116432Designator
;
70 void * ImplCreateIso2022CnToUnicodeContext()
72 ImplIso2022CnToUnicodeContext
* pContext
=
73 new ImplIso2022CnToUnicodeContext
;
74 pContext
->m_eState
= IMPL_ISO_2022_CN_TO_UNICODE_STATE_ASCII
;
75 pContext
->m_bSo
= false;
76 pContext
->m_b116431
= false;
80 void ImplResetIso2022CnToUnicodeContext(void * pContext
)
84 static_cast< ImplIso2022CnToUnicodeContext
* >(pContext
)->m_eState
85 = IMPL_ISO_2022_CN_TO_UNICODE_STATE_ASCII
;
86 static_cast< ImplIso2022CnToUnicodeContext
* >(pContext
)->m_bSo
= false;
87 static_cast< ImplIso2022CnToUnicodeContext
* >(pContext
)->m_b116431
= false;
91 void ImplDestroyIso2022CnToUnicodeContext(void * pContext
)
93 delete static_cast< ImplIso2022CnToUnicodeContext
* >(pContext
);
96 sal_Size
ImplConvertIso2022CnToUnicode(void const * pData
,
100 sal_Unicode
* pDestBuf
,
104 sal_Size
* pSrcCvtBytes
)
106 ImplDBCSToUniLeadTab
const * pGb2312Data
107 = static_cast< ImplIso2022CnConverterData
const * >(pData
)->
108 m_pGb2312ToUnicodeData
;
109 sal_uInt16
const * pCns116431992Data
110 = static_cast< ImplIso2022CnConverterData
const * >(pData
)->
111 m_pCns116431992ToUnicodeData
;
112 sal_Int32
const * pCns116431992RowOffsets
113 = static_cast< ImplIso2022CnConverterData
const * >(pData
)->
114 m_pCns116431992ToUnicodeRowOffsets
;
115 sal_Int32
const * pCns116431992PlaneOffsets
116 = static_cast< ImplIso2022CnConverterData
const * >(pData
)->
117 m_pCns116431992ToUnicodePlaneOffsets
;
118 ImplIso2022CnToUnicodeState eState
119 = IMPL_ISO_2022_CN_TO_UNICODE_STATE_ASCII
;
122 bool b116431
= false;
123 sal_uInt32 nInfo
= 0;
124 sal_Size nConverted
= 0;
125 sal_Unicode
* pDestBufPtr
= pDestBuf
;
126 sal_Unicode
* pDestBufEnd
= pDestBuf
+ nDestChars
;
130 eState
= static_cast< ImplIso2022CnToUnicodeContext
* >(pContext
)->m_eState
;
131 nRow
= static_cast< ImplIso2022CnToUnicodeContext
* >(pContext
)->m_nRow
;
132 bSo
= static_cast< ImplIso2022CnToUnicodeContext
* >(pContext
)->m_bSo
;
133 b116431
= static_cast< ImplIso2022CnToUnicodeContext
* >(pContext
)->m_b116431
;
136 for (; nConverted
< nSrcBytes
; ++nConverted
)
138 bool bUndefined
= true;
139 sal_uInt32 nChar
= *reinterpret_cast<unsigned char const *>(pSrcBuf
++);
143 case IMPL_ISO_2022_CN_TO_UNICODE_STATE_ASCII
:
144 if (nChar
== 0x0E) // SO
147 eState
= IMPL_ISO_2022_CN_TO_UNICODE_STATE_SO
;
149 else if (nChar
== 0x1B) // ESC
150 eState
= IMPL_ISO_2022_CN_TO_UNICODE_STATE_ESC
;
151 else if (nChar
< 0x80)
152 if (pDestBufPtr
!= pDestBufEnd
)
153 *pDestBufPtr
++ = static_cast<sal_Unicode
>(nChar
);
163 case IMPL_ISO_2022_CN_TO_UNICODE_STATE_SO
:
164 if (nChar
== 0x0F) // SI
167 eState
= IMPL_ISO_2022_CN_TO_UNICODE_STATE_ASCII
;
169 else if (nChar
== 0x1B) // ESC
170 eState
= IMPL_ISO_2022_CN_TO_UNICODE_STATE_ESC
;
171 else if (nChar
>= 0x21 && nChar
<= 0x7E)
174 eState
= IMPL_ISO_2022_CN_TO_UNICODE_STATE_SO_2
;
183 case IMPL_ISO_2022_CN_TO_UNICODE_STATE_SO_2
:
184 if (nChar
>= 0x21 && nChar
<= 0x7E)
192 sal_uInt16 nUnicode
= 0;
196 nFirst
= pGb2312Data
[nRow
].mnTrailStart
;
198 && nChar
<= pGb2312Data
[nRow
].mnTrailEnd
)
199 nUnicode
= pGb2312Data
[nRow
].
200 mpToUniTrailTab
[nChar
- nFirst
];
202 if (pDestBufPtr
!= pDestBufEnd
)
204 *pDestBufPtr
++ = static_cast<sal_Unicode
>(nUnicode
);
205 eState
= IMPL_ISO_2022_CN_TO_UNICODE_STATE_SO
;
219 case IMPL_ISO_2022_CN_TO_UNICODE_STATE_116432
:
220 if (nChar
>= 0x21 && nChar
<= 0x7E)
223 eState
= IMPL_ISO_2022_CN_TO_UNICODE_STATE_116432_2
;
232 case IMPL_ISO_2022_CN_TO_UNICODE_STATE_116432_2
:
233 if (nChar
>= 0x21 && nChar
<= 0x7E)
245 case IMPL_ISO_2022_CN_TO_UNICODE_STATE_ESC
:
246 if (nChar
== 0x24) // $
247 eState
= IMPL_ISO_2022_CN_TO_UNICODE_STATE_ESC_DOLLAR
;
248 else if (nChar
== 0x4E) // N
249 eState
= IMPL_ISO_2022_CN_TO_UNICODE_STATE_116432
;
257 case IMPL_ISO_2022_CN_TO_UNICODE_STATE_ESC_DOLLAR
:
258 if (nChar
== 0x29) // )
259 eState
= IMPL_ISO_2022_CN_TO_UNICODE_STATE_ESC_DOLLAR_RPAREN
;
260 else if (nChar
== 0x2A) // *
262 = IMPL_ISO_2022_CN_TO_UNICODE_STATE_ESC_DOLLAR_ASTERISK
;
270 case IMPL_ISO_2022_CN_TO_UNICODE_STATE_ESC_DOLLAR_RPAREN
:
271 if (nChar
== 0x41) // A
274 eState
= bSo
? IMPL_ISO_2022_CN_TO_UNICODE_STATE_SO
:
275 IMPL_ISO_2022_CN_TO_UNICODE_STATE_ASCII
;
277 else if (nChar
== 0x47) // G
280 eState
= bSo
? IMPL_ISO_2022_CN_TO_UNICODE_STATE_SO
:
281 IMPL_ISO_2022_CN_TO_UNICODE_STATE_ASCII
;
290 case IMPL_ISO_2022_CN_TO_UNICODE_STATE_ESC_DOLLAR_ASTERISK
:
291 if (nChar
== 0x48) // H
292 eState
= bSo
? IMPL_ISO_2022_CN_TO_UNICODE_STATE_SO
:
293 IMPL_ISO_2022_CN_TO_UNICODE_STATE_ASCII
;
305 sal_Int32 nPlaneOffset
= pCns116431992PlaneOffsets
[nPlane
];
306 if (nPlaneOffset
== -1)
311 = pCns116431992RowOffsets
[nPlaneOffset
+ (nRow
- 0x21)];
316 sal_uInt32 nFirstLast
= pCns116431992Data
[nOffset
++];
317 sal_uInt32 nFirst
= nFirstLast
& 0xFF;
318 sal_uInt32 nLast
= nFirstLast
>> 8;
320 if (nChar
>= nFirst
&& nChar
<= nLast
)
323 = pCns116431992Data
[nOffset
+ (nChar
- nFirst
)];
324 if (nUnicode
== 0xFFFF)
326 else if (ImplIsHighSurrogate(nUnicode
))
327 if (pDestBufEnd
- pDestBufPtr
>= 2)
329 nOffset
+= nLast
- nFirst
+ 1;
330 nFirst
= pCns116431992Data
[nOffset
++];
331 *pDestBufPtr
++ = static_cast<sal_Unicode
>(nUnicode
);
333 = static_cast<sal_Unicode
>(pCns116431992Data
[
334 nOffset
+ (nChar
- nFirst
)]);
339 if (pDestBufPtr
!= pDestBufEnd
)
340 *pDestBufPtr
++ = static_cast<sal_Unicode
>(nUnicode
);
346 eState
= bSo
? IMPL_ISO_2022_CN_TO_UNICODE_STATE_SO
:
347 IMPL_ISO_2022_CN_TO_UNICODE_STATE_ASCII
;
354 switch (sal::detail::textenc::handleBadInputTextToUnicodeConversion(
355 bUndefined
, true, 0, nFlags
, &pDestBufPtr
, pDestBufEnd
,
358 case sal::detail::textenc::BAD_INPUT_STOP
:
359 eState
= IMPL_ISO_2022_CN_TO_UNICODE_STATE_ASCII
;
363 case sal::detail::textenc::BAD_INPUT_CONTINUE
:
364 eState
= IMPL_ISO_2022_CN_TO_UNICODE_STATE_ASCII
;
368 case sal::detail::textenc::BAD_INPUT_NO_OUTPUT
:
375 nInfo
|= RTL_TEXTTOUNICODE_INFO_DESTBUFFERTOOSMALL
;
379 if (eState
> IMPL_ISO_2022_CN_TO_UNICODE_STATE_SO
380 && (nInfo
& (RTL_TEXTTOUNICODE_INFO_ERROR
381 | RTL_TEXTTOUNICODE_INFO_DESTBUFFERTOOSMALL
))
384 if ((nFlags
& RTL_TEXTTOUNICODE_FLAGS_FLUSH
) == 0)
385 nInfo
|= RTL_TEXTTOUNICODE_INFO_SRCBUFFERTOOSMALL
;
387 switch (sal::detail::textenc::handleBadInputTextToUnicodeConversion(
388 false, true, 0, nFlags
, &pDestBufPtr
, pDestBufEnd
,
391 case sal::detail::textenc::BAD_INPUT_STOP
:
392 case sal::detail::textenc::BAD_INPUT_CONTINUE
:
393 eState
= IMPL_ISO_2022_CN_TO_UNICODE_STATE_ASCII
;
397 case sal::detail::textenc::BAD_INPUT_NO_OUTPUT
:
398 nInfo
|= RTL_TEXTTOUNICODE_INFO_DESTBUFFERTOOSMALL
;
405 static_cast< ImplIso2022CnToUnicodeContext
* >(pContext
)->m_eState
= eState
;
406 static_cast< ImplIso2022CnToUnicodeContext
* >(pContext
)->m_nRow
= nRow
;
407 static_cast< ImplIso2022CnToUnicodeContext
* >(pContext
)->m_bSo
= bSo
;
408 static_cast< ImplIso2022CnToUnicodeContext
* >(pContext
)->m_b116431
= b116431
;
413 *pSrcCvtBytes
= nConverted
;
415 return pDestBufPtr
- pDestBuf
;
418 void * ImplCreateUnicodeToIso2022CnContext()
420 ImplUnicodeToIso2022CnContext
* pContext
=
421 new ImplUnicodeToIso2022CnContext
;
422 pContext
->m_nHighSurrogate
= 0;
423 pContext
->m_eSoDesignator
= IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_NONE
;
424 pContext
->m_b116432Designator
= false;
425 pContext
->m_bSo
= false;
429 void ImplResetUnicodeToIso2022CnContext(void * pContext
)
433 static_cast< ImplUnicodeToIso2022CnContext
* >(pContext
)->m_nHighSurrogate
= 0;
434 static_cast< ImplUnicodeToIso2022CnContext
* >(pContext
)->m_eSoDesignator
435 = IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_NONE
;
436 static_cast< ImplUnicodeToIso2022CnContext
* >(pContext
)->m_b116432Designator
438 static_cast< ImplUnicodeToIso2022CnContext
* >(pContext
)->m_bSo
= false;
442 void ImplDestroyUnicodeToIso2022CnContext(void * pContext
)
444 delete static_cast< ImplUnicodeToIso2022CnContext
* >(pContext
);
447 static sal_uInt32
ImplIso2022CnTranslateTo2312(ImplUniToDBCSHighTab
const *
451 sal_uInt32 nIndex1
= nChar
>> 8;
454 sal_uInt32 nIndex2
= nChar
& 0xFF;
455 sal_uInt32 nFirst
= pGb2312Data
[nIndex1
].mnLowStart
;
456 if (nIndex2
>= nFirst
&& nIndex2
<= pGb2312Data
[nIndex1
].mnLowEnd
)
457 return pGb2312Data
[nIndex1
].mpToUniTrailTab
[nIndex2
- nFirst
]
464 ImplIso2022CnTranslateTo116431(sal_uInt8
const * pCns116431992Data
,
465 sal_Int32
const * pCns116431992PageOffsets
,
466 sal_Int32
const * pCns116431992PlaneOffsets
,
469 sal_Int32 nOffset
= pCns116431992PlaneOffsets
[nChar
>> 16];
475 nOffset
= pCns116431992PageOffsets
[nOffset
+ ((nChar
& 0xFF00) >> 8)];
478 nFirst
= pCns116431992Data
[nOffset
++];
479 nLast
= pCns116431992Data
[nOffset
++];
481 if (nChar
< nFirst
|| nChar
> nLast
)
483 nOffset
+= 3 * (nChar
- nFirst
);
484 nPlane
= pCns116431992Data
[nOffset
++];
487 return (0x20 + pCns116431992Data
[nOffset
]) << 8
488 | (0x20 + pCns116431992Data
[nOffset
+ 1]);
491 sal_Size
ImplConvertUnicodeToIso2022Cn(void const * pData
,
493 sal_Unicode
const * pSrcBuf
,
499 sal_Size
* pSrcCvtChars
)
501 ImplUniToDBCSHighTab
const * pGb2312Data
502 = static_cast< ImplIso2022CnConverterData
const * >(pData
)->
503 m_pUnicodeToGb2312Data
;
504 sal_uInt8
const * pCns116431992Data
505 = static_cast< ImplIso2022CnConverterData
const * >(pData
)->
506 m_pUnicodeToCns116431992Data
;
507 sal_Int32
const * pCns116431992PageOffsets
508 = static_cast< ImplIso2022CnConverterData
const * >(pData
)->
509 m_pUnicodeToCns116431992PageOffsets
;
510 sal_Int32
const * pCns116431992PlaneOffsets
511 = static_cast< ImplIso2022CnConverterData
const * >(pData
)->
512 m_pUnicodeToCns116431992PlaneOffsets
;
513 sal_Unicode nHighSurrogate
= 0;
514 ImplUnicodeToIso2022CnDesignator eSoDesignator
515 = IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_NONE
;
516 bool b116432Designator
= false;
518 sal_uInt32 nInfo
= 0;
519 sal_Size nConverted
= 0;
520 char * pDestBufPtr
= pDestBuf
;
521 char * pDestBufEnd
= pDestBuf
+ nDestBytes
;
527 = static_cast< ImplUnicodeToIso2022CnContext
* >(pContext
)->m_nHighSurrogate
;
529 = static_cast< ImplUnicodeToIso2022CnContext
* >(pContext
)->m_eSoDesignator
;
530 b116432Designator
= static_cast< ImplUnicodeToIso2022CnContext
* >(pContext
)->
532 bSo
= static_cast< ImplUnicodeToIso2022CnContext
* >(pContext
)->m_bSo
;
535 for (; nConverted
< nSrcChars
; ++nConverted
)
537 bool bUndefined
= true;
538 sal_uInt32 nChar
= *pSrcBuf
++;
539 if (nHighSurrogate
== 0)
541 if (ImplIsHighSurrogate(nChar
))
543 nHighSurrogate
= static_cast<sal_Unicode
>(nChar
);
547 else if (ImplIsLowSurrogate(nChar
))
548 nChar
= ImplCombineSurrogates(nHighSurrogate
, nChar
);
555 if (ImplIsLowSurrogate(nChar
) || ImplIsNoncharacter(nChar
))
561 if (nChar
== 0x0A || nChar
== 0x0D) // LF, CR
565 if (pDestBufPtr
!= pDestBufEnd
)
567 *pDestBufPtr
++ = 0x0F; // SI
570 = IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_NONE
;
571 b116432Designator
= false;
576 if (pDestBufPtr
!= pDestBufEnd
)
577 *pDestBufPtr
++ = static_cast< char >(nChar
);
581 else if (nChar
== 0x0E || nChar
== 0x0F || nChar
== 0x1B)
583 else if (nChar
< 0x80)
587 if (pDestBufPtr
!= pDestBufEnd
)
589 *pDestBufPtr
++ = 0x0F; // SI
595 if (pDestBufPtr
!= pDestBufEnd
)
596 *pDestBufPtr
++ = static_cast< char >(nChar
);
602 sal_uInt32 nBytes
= 0;
603 ImplUnicodeToIso2022CnDesignator eNewDesignator
=
604 IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_NONE
;
605 switch (eSoDesignator
)
607 case IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_NONE
:
608 nBytes
= ImplIso2022CnTranslateTo2312(pGb2312Data
, nChar
);
612 = IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_2312
;
615 nBytes
= ImplIso2022CnTranslateTo116431(
617 pCns116431992PageOffsets
,
618 pCns116431992PlaneOffsets
,
623 = IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_116431
;
628 case IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_2312
:
629 nBytes
= ImplIso2022CnTranslateTo2312(pGb2312Data
, nChar
);
633 = IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_NONE
;
636 nBytes
= ImplIso2022CnTranslateTo116431(
638 pCns116431992PageOffsets
,
639 pCns116431992PlaneOffsets
,
644 = IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_116431
;
649 case IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_116431
:
650 nBytes
= ImplIso2022CnTranslateTo116431(
652 pCns116431992PageOffsets
,
653 pCns116431992PlaneOffsets
,
658 = IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_NONE
;
661 nBytes
= ImplIso2022CnTranslateTo2312(pGb2312Data
, nChar
);
665 = IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_2312
;
673 != IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_NONE
)
677 if (pDestBufPtr
!= pDestBufEnd
)
679 *pDestBufPtr
++ = 0x0F; // SI
685 if (pDestBufEnd
- pDestBufPtr
>= 4)
687 *pDestBufPtr
++ = 0x1B; // ESC
688 *pDestBufPtr
++ = 0x24; // $
689 *pDestBufPtr
++ = 0x29; // )
692 == IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_2312
?
694 eSoDesignator
= eNewDesignator
;
701 if (pDestBufPtr
!= pDestBufEnd
)
703 *pDestBufPtr
++ = 0x0E; // SO
709 if (pDestBufEnd
- pDestBufPtr
>= 4)
711 *pDestBufPtr
++ = static_cast< char >(nBytes
>> 8);
712 *pDestBufPtr
++ = static_cast< char >(nBytes
& 0xFF);
719 sal_Int32 nOffset
= pCns116431992PlaneOffsets
[nChar
>> 16];
726 = pCns116431992PageOffsets
[nOffset
727 + ((nChar
& 0xFF00) >> 8)];
730 nFirst
= pCns116431992Data
[nOffset
++];
731 nLast
= pCns116431992Data
[nOffset
++];
733 if (nChar
< nFirst
|| nChar
> nLast
)
735 nOffset
+= 3 * (nChar
- nFirst
);
736 nPlane
= pCns116431992Data
[nOffset
++];
739 if (!b116432Designator
)
741 if (pDestBufEnd
- pDestBufPtr
>= 4)
743 *pDestBufPtr
++ = 0x1B; // ESC
744 *pDestBufPtr
++ = 0x24; // $
745 *pDestBufPtr
++ = 0x2A; // *
746 *pDestBufPtr
++ = 0x48; // H
747 b116432Designator
= true;
752 if (pDestBufEnd
- pDestBufPtr
>= 4)
754 *pDestBufPtr
++ = 0x1B; // ESC
755 *pDestBufPtr
++ = 0x4E; // N
757 = static_cast< char >(0x20 + pCns116431992Data
[nOffset
++]);
759 = static_cast< char >(0x20 + pCns116431992Data
[nOffset
]);
769 switch (sal::detail::textenc::handleBadInputUnicodeToTextConversion(
770 bUndefined
, nChar
, nFlags
, &pDestBufPtr
, pDestBufEnd
,
771 &nInfo
, "\x0F" /* SI */, bSo
? 1 : 0, &bWritten
))
773 case sal::detail::textenc::BAD_INPUT_STOP
:
777 case sal::detail::textenc::BAD_INPUT_CONTINUE
:
783 case sal::detail::textenc::BAD_INPUT_NO_OUTPUT
:
790 nInfo
|= RTL_UNICODETOTEXT_INFO_DESTBUFFERTOSMALL
;
794 if ((nInfo
& (RTL_UNICODETOTEXT_INFO_ERROR
795 | RTL_UNICODETOTEXT_INFO_DESTBUFFERTOSMALL
))
799 if (nHighSurrogate
!= 0)
801 if ((nFlags
& RTL_UNICODETOTEXT_FLAGS_FLUSH
) != 0)
802 nInfo
|= RTL_UNICODETOTEXT_INFO_SRCBUFFERTOSMALL
;
804 switch (sal::detail::textenc::handleBadInputUnicodeToTextConversion(
805 false, 0, nFlags
, &pDestBufPtr
, pDestBufEnd
, &nInfo
,
806 "\x0F" /* SI */, bSo
? 1 : 0, &bWritten
))
808 case sal::detail::textenc::BAD_INPUT_STOP
:
813 case sal::detail::textenc::BAD_INPUT_CONTINUE
:
819 case sal::detail::textenc::BAD_INPUT_NO_OUTPUT
:
820 nInfo
|= RTL_UNICODETOTEXT_INFO_DESTBUFFERTOSMALL
;
824 if (bFlush
&& bSo
&& (nFlags
& RTL_UNICODETOTEXT_FLAGS_FLUSH
) != 0)
826 if (pDestBufPtr
!= pDestBufEnd
)
828 *pDestBufPtr
++ = 0x0F; // SI
832 nInfo
|= RTL_UNICODETOTEXT_INFO_DESTBUFFERTOSMALL
;
838 static_cast< ImplUnicodeToIso2022CnContext
* >(pContext
)->m_nHighSurrogate
840 static_cast< ImplUnicodeToIso2022CnContext
* >(pContext
)->m_eSoDesignator
842 static_cast< ImplUnicodeToIso2022CnContext
* >(pContext
)->m_b116432Designator
844 static_cast< ImplUnicodeToIso2022CnContext
* >(pContext
)->m_bSo
= bSo
;
849 *pSrcCvtChars
= nConverted
;
851 return pDestBufPtr
- pDestBuf
;
854 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */