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
++ = (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
++ = (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
++ = (sal_Unicode
) nUnicode
;
335 nOffset
+ (nChar
- nFirst
)];
340 if (pDestBufPtr
!= pDestBufEnd
)
341 *pDestBufPtr
++ = (sal_Unicode
) nUnicode
;
347 eState
= bSo
? IMPL_ISO_2022_CN_TO_UNICODE_STATE_SO
:
348 IMPL_ISO_2022_CN_TO_UNICODE_STATE_ASCII
;
355 switch (sal::detail::textenc::handleBadInputTextToUnicodeConversion(
356 bUndefined
, true, 0, nFlags
, &pDestBufPtr
, pDestBufEnd
,
359 case sal::detail::textenc::BAD_INPUT_STOP
:
360 eState
= IMPL_ISO_2022_CN_TO_UNICODE_STATE_ASCII
;
364 case sal::detail::textenc::BAD_INPUT_CONTINUE
:
365 eState
= IMPL_ISO_2022_CN_TO_UNICODE_STATE_ASCII
;
369 case sal::detail::textenc::BAD_INPUT_NO_OUTPUT
:
376 nInfo
|= RTL_TEXTTOUNICODE_INFO_DESTBUFFERTOSMALL
;
380 if (eState
> IMPL_ISO_2022_CN_TO_UNICODE_STATE_SO
381 && (nInfo
& (RTL_TEXTTOUNICODE_INFO_ERROR
382 | RTL_TEXTTOUNICODE_INFO_DESTBUFFERTOSMALL
))
385 if ((nFlags
& RTL_TEXTTOUNICODE_FLAGS_FLUSH
) == 0)
386 nInfo
|= RTL_TEXTTOUNICODE_INFO_SRCBUFFERTOSMALL
;
388 switch (sal::detail::textenc::handleBadInputTextToUnicodeConversion(
389 false, true, 0, nFlags
, &pDestBufPtr
, pDestBufEnd
,
392 case sal::detail::textenc::BAD_INPUT_STOP
:
393 case sal::detail::textenc::BAD_INPUT_CONTINUE
:
394 eState
= IMPL_ISO_2022_CN_TO_UNICODE_STATE_ASCII
;
398 case sal::detail::textenc::BAD_INPUT_NO_OUTPUT
:
399 nInfo
|= RTL_TEXTTOUNICODE_INFO_DESTBUFFERTOSMALL
;
406 static_cast< ImplIso2022CnToUnicodeContext
* >(pContext
)->m_eState
= eState
;
407 static_cast< ImplIso2022CnToUnicodeContext
* >(pContext
)->m_nRow
= nRow
;
408 static_cast< ImplIso2022CnToUnicodeContext
* >(pContext
)->m_bSo
= bSo
;
409 static_cast< ImplIso2022CnToUnicodeContext
* >(pContext
)->m_b116431
= b116431
;
414 *pSrcCvtBytes
= nConverted
;
416 return pDestBufPtr
- pDestBuf
;
419 void * ImplCreateUnicodeToIso2022CnContext()
421 ImplUnicodeToIso2022CnContext
* pContext
=
422 new ImplUnicodeToIso2022CnContext
;
423 pContext
->m_nHighSurrogate
= 0;
424 pContext
->m_eSoDesignator
= IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_NONE
;
425 pContext
->m_b116432Designator
= false;
426 pContext
->m_bSo
= false;
430 void ImplResetUnicodeToIso2022CnContext(void * pContext
)
434 static_cast< ImplUnicodeToIso2022CnContext
* >(pContext
)->m_nHighSurrogate
= 0;
435 static_cast< ImplUnicodeToIso2022CnContext
* >(pContext
)->m_eSoDesignator
436 = IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_NONE
;
437 static_cast< ImplUnicodeToIso2022CnContext
* >(pContext
)->m_b116432Designator
439 static_cast< ImplUnicodeToIso2022CnContext
* >(pContext
)->m_bSo
= false;
443 void ImplDestroyUnicodeToIso2022CnContext(void * pContext
)
445 delete static_cast< ImplUnicodeToIso2022CnContext
* >(pContext
);
448 static sal_uInt32
ImplIso2022CnTranslateTo2312(ImplUniToDBCSHighTab
const *
452 sal_uInt32 nIndex1
= nChar
>> 8;
455 sal_uInt32 nIndex2
= nChar
& 0xFF;
456 sal_uInt32 nFirst
= pGb2312Data
[nIndex1
].mnLowStart
;
457 if (nIndex2
>= nFirst
&& nIndex2
<= pGb2312Data
[nIndex1
].mnLowEnd
)
458 return pGb2312Data
[nIndex1
].mpToUniTrailTab
[nIndex2
- nFirst
]
465 ImplIso2022CnTranslateTo116431(sal_uInt8
const * pCns116431992Data
,
466 sal_Int32
const * pCns116431992PageOffsets
,
467 sal_Int32
const * pCns116431992PlaneOffsets
,
470 sal_Int32 nOffset
= pCns116431992PlaneOffsets
[nChar
>> 16];
476 nOffset
= pCns116431992PageOffsets
[nOffset
+ ((nChar
& 0xFF00) >> 8)];
479 nFirst
= pCns116431992Data
[nOffset
++];
480 nLast
= pCns116431992Data
[nOffset
++];
482 if (nChar
< nFirst
|| nChar
> nLast
)
484 nOffset
+= 3 * (nChar
- nFirst
);
485 nPlane
= pCns116431992Data
[nOffset
++];
488 return (0x20 + pCns116431992Data
[nOffset
]) << 8
489 | (0x20 + pCns116431992Data
[nOffset
+ 1]);
492 sal_Size
ImplConvertUnicodeToIso2022Cn(void const * pData
,
494 sal_Unicode
const * pSrcBuf
,
500 sal_Size
* pSrcCvtChars
)
502 ImplUniToDBCSHighTab
const * pGb2312Data
503 = static_cast< ImplIso2022CnConverterData
const * >(pData
)->
504 m_pUnicodeToGb2312Data
;
505 sal_uInt8
const * pCns116431992Data
506 = static_cast< ImplIso2022CnConverterData
const * >(pData
)->
507 m_pUnicodeToCns116431992Data
;
508 sal_Int32
const * pCns116431992PageOffsets
509 = static_cast< ImplIso2022CnConverterData
const * >(pData
)->
510 m_pUnicodeToCns116431992PageOffsets
;
511 sal_Int32
const * pCns116431992PlaneOffsets
512 = static_cast< ImplIso2022CnConverterData
const * >(pData
)->
513 m_pUnicodeToCns116431992PlaneOffsets
;
514 sal_Unicode nHighSurrogate
= 0;
515 ImplUnicodeToIso2022CnDesignator eSoDesignator
516 = IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_NONE
;
517 bool b116432Designator
= false;
519 sal_uInt32 nInfo
= 0;
520 sal_Size nConverted
= 0;
521 char * pDestBufPtr
= pDestBuf
;
522 char * pDestBufEnd
= pDestBuf
+ nDestBytes
;
528 = static_cast< ImplUnicodeToIso2022CnContext
* >(pContext
)->m_nHighSurrogate
;
530 = static_cast< ImplUnicodeToIso2022CnContext
* >(pContext
)->m_eSoDesignator
;
531 b116432Designator
= static_cast< ImplUnicodeToIso2022CnContext
* >(pContext
)->
533 bSo
= static_cast< ImplUnicodeToIso2022CnContext
* >(pContext
)->m_bSo
;
536 for (; nConverted
< nSrcChars
; ++nConverted
)
538 bool bUndefined
= true;
539 sal_uInt32 nChar
= *pSrcBuf
++;
540 if (nHighSurrogate
== 0)
542 if (ImplIsHighSurrogate(nChar
))
544 nHighSurrogate
= (sal_Unicode
) nChar
;
548 else if (ImplIsLowSurrogate(nChar
))
549 nChar
= ImplCombineSurrogates(nHighSurrogate
, nChar
);
556 if (ImplIsLowSurrogate(nChar
) || ImplIsNoncharacter(nChar
))
562 if (nChar
== 0x0A || nChar
== 0x0D) // LF, CR
566 if (pDestBufPtr
!= pDestBufEnd
)
568 *pDestBufPtr
++ = 0x0F; // SI
571 = IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_NONE
;
572 b116432Designator
= false;
577 if (pDestBufPtr
!= pDestBufEnd
)
578 *pDestBufPtr
++ = static_cast< char >(nChar
);
582 else if (nChar
== 0x0E || nChar
== 0x0F || nChar
== 0x1B)
584 else if (nChar
< 0x80)
588 if (pDestBufPtr
!= pDestBufEnd
)
590 *pDestBufPtr
++ = 0x0F; // SI
596 if (pDestBufPtr
!= pDestBufEnd
)
597 *pDestBufPtr
++ = static_cast< char >(nChar
);
603 sal_uInt32 nBytes
= 0;
604 ImplUnicodeToIso2022CnDesignator eNewDesignator
=
605 IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_NONE
;
606 switch (eSoDesignator
)
608 case IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_NONE
:
609 nBytes
= ImplIso2022CnTranslateTo2312(pGb2312Data
, nChar
);
613 = IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_2312
;
616 nBytes
= ImplIso2022CnTranslateTo116431(
618 pCns116431992PageOffsets
,
619 pCns116431992PlaneOffsets
,
624 = IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_116431
;
629 case IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_2312
:
630 nBytes
= ImplIso2022CnTranslateTo2312(pGb2312Data
, nChar
);
634 = IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_NONE
;
637 nBytes
= ImplIso2022CnTranslateTo116431(
639 pCns116431992PageOffsets
,
640 pCns116431992PlaneOffsets
,
645 = IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_116431
;
650 case IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_116431
:
651 nBytes
= ImplIso2022CnTranslateTo116431(
653 pCns116431992PageOffsets
,
654 pCns116431992PlaneOffsets
,
659 = IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_NONE
;
662 nBytes
= ImplIso2022CnTranslateTo2312(pGb2312Data
, nChar
);
666 = IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_2312
;
674 != IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_NONE
)
678 if (pDestBufPtr
!= pDestBufEnd
)
680 *pDestBufPtr
++ = 0x0F; // SI
686 if (pDestBufEnd
- pDestBufPtr
>= 4)
688 *pDestBufPtr
++ = 0x1B; // ESC
689 *pDestBufPtr
++ = 0x24; // $
690 *pDestBufPtr
++ = 0x29; // )
693 == IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_2312
?
695 eSoDesignator
= eNewDesignator
;
702 if (pDestBufPtr
!= pDestBufEnd
)
704 *pDestBufPtr
++ = 0x0E; // SO
710 if (pDestBufEnd
- pDestBufPtr
>= 4)
712 *pDestBufPtr
++ = static_cast< char >(nBytes
>> 8);
713 *pDestBufPtr
++ = static_cast< char >(nBytes
& 0xFF);
720 sal_Int32 nOffset
= pCns116431992PlaneOffsets
[nChar
>> 16];
727 = pCns116431992PageOffsets
[nOffset
728 + ((nChar
& 0xFF00) >> 8)];
731 nFirst
= pCns116431992Data
[nOffset
++];
732 nLast
= pCns116431992Data
[nOffset
++];
734 if (nChar
< nFirst
|| nChar
> nLast
)
736 nOffset
+= 3 * (nChar
- nFirst
);
737 nPlane
= pCns116431992Data
[nOffset
++];
740 if (!b116432Designator
)
742 if (pDestBufEnd
- pDestBufPtr
>= 4)
744 *pDestBufPtr
++ = 0x1B; // ESC
745 *pDestBufPtr
++ = 0x24; // $
746 *pDestBufPtr
++ = 0x2A; // *
747 *pDestBufPtr
++ = 0x48; // H
748 b116432Designator
= true;
753 if (pDestBufEnd
- pDestBufPtr
>= 4)
755 *pDestBufPtr
++ = 0x1B; // ESC
756 *pDestBufPtr
++ = 0x4E; // N
758 = static_cast< char >(0x20 + pCns116431992Data
[nOffset
++]);
760 = static_cast< char >(0x20 + pCns116431992Data
[nOffset
]);
770 switch (sal::detail::textenc::handleBadInputUnicodeToTextConversion(
771 bUndefined
, nChar
, nFlags
, &pDestBufPtr
, pDestBufEnd
,
772 &nInfo
, "\x0F" /* SI */, bSo
? 1 : 0, &bWritten
))
774 case sal::detail::textenc::BAD_INPUT_STOP
:
778 case sal::detail::textenc::BAD_INPUT_CONTINUE
:
784 case sal::detail::textenc::BAD_INPUT_NO_OUTPUT
:
791 nInfo
|= RTL_UNICODETOTEXT_INFO_DESTBUFFERTOSMALL
;
795 if ((nInfo
& (RTL_UNICODETOTEXT_INFO_ERROR
796 | RTL_UNICODETOTEXT_INFO_DESTBUFFERTOSMALL
))
800 if (nHighSurrogate
!= 0)
802 if ((nFlags
& RTL_UNICODETOTEXT_FLAGS_FLUSH
) != 0)
803 nInfo
|= RTL_UNICODETOTEXT_INFO_SRCBUFFERTOSMALL
;
805 switch (sal::detail::textenc::handleBadInputUnicodeToTextConversion(
806 false, 0, nFlags
, &pDestBufPtr
, pDestBufEnd
, &nInfo
,
807 "\x0F" /* SI */, bSo
? 1 : 0, &bWritten
))
809 case sal::detail::textenc::BAD_INPUT_STOP
:
814 case sal::detail::textenc::BAD_INPUT_CONTINUE
:
820 case sal::detail::textenc::BAD_INPUT_NO_OUTPUT
:
821 nInfo
|= RTL_UNICODETOTEXT_INFO_DESTBUFFERTOSMALL
;
825 if (bFlush
&& bSo
&& (nFlags
& RTL_UNICODETOTEXT_FLAGS_FLUSH
) != 0)
827 if (pDestBufPtr
!= pDestBufEnd
)
829 *pDestBufPtr
++ = 0x0F; // SI
833 nInfo
|= RTL_UNICODETOTEXT_INFO_DESTBUFFERTOSMALL
;
839 static_cast< ImplUnicodeToIso2022CnContext
* >(pContext
)->m_nHighSurrogate
841 static_cast< ImplUnicodeToIso2022CnContext
* >(pContext
)->m_eSoDesignator
843 static_cast< ImplUnicodeToIso2022CnContext
* >(pContext
)->m_b116432Designator
845 static_cast< ImplUnicodeToIso2022CnContext
* >(pContext
)->m_bSo
= bSo
;
850 *pSrcCvtChars
= nConverted
;
852 return pDestBufPtr
- pDestBuf
;
855 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */