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 "context.hxx"
26 #include "converter.hxx"
27 #include "convertiso2022cn.hxx"
28 #include "tenchelp.hxx"
29 #include "unichars.hxx"
33 enum ImplIso2022CnToUnicodeState
// order is important:
35 IMPL_ISO_2022_CN_TO_UNICODE_STATE_ASCII
,
36 IMPL_ISO_2022_CN_TO_UNICODE_STATE_SO
,
37 IMPL_ISO_2022_CN_TO_UNICODE_STATE_SO_2
,
38 IMPL_ISO_2022_CN_TO_UNICODE_STATE_116432
,
39 IMPL_ISO_2022_CN_TO_UNICODE_STATE_116432_2
,
40 IMPL_ISO_2022_CN_TO_UNICODE_STATE_ESC
,
41 IMPL_ISO_2022_CN_TO_UNICODE_STATE_ESC_DOLLAR
,
42 IMPL_ISO_2022_CN_TO_UNICODE_STATE_ESC_DOLLAR_RPAREN
,
43 IMPL_ISO_2022_CN_TO_UNICODE_STATE_ESC_DOLLAR_ASTERISK
46 struct ImplIso2022CnToUnicodeContext
48 ImplIso2022CnToUnicodeState m_eState
;
54 enum ImplUnicodeToIso2022CnDesignator
56 IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_NONE
,
57 IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_2312
,
58 IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_116431
61 struct ImplUnicodeToIso2022CnContext
63 sal_Unicode m_nHighSurrogate
;
64 ImplUnicodeToIso2022CnDesignator m_eSoDesignator
;
65 bool m_b116432Designator
;
71 void * ImplCreateIso2022CnToUnicodeContext()
73 ImplIso2022CnToUnicodeContext
* pContext
=
74 new ImplIso2022CnToUnicodeContext
;
75 pContext
->m_eState
= IMPL_ISO_2022_CN_TO_UNICODE_STATE_ASCII
;
76 pContext
->m_bSo
= false;
77 pContext
->m_b116431
= false;
81 void ImplResetIso2022CnToUnicodeContext(void * pContext
)
85 static_cast< ImplIso2022CnToUnicodeContext
* >(pContext
)->m_eState
86 = IMPL_ISO_2022_CN_TO_UNICODE_STATE_ASCII
;
87 static_cast< ImplIso2022CnToUnicodeContext
* >(pContext
)->m_bSo
= false;
88 static_cast< ImplIso2022CnToUnicodeContext
* >(pContext
)->m_b116431
= false;
92 void ImplDestroyIso2022CnToUnicodeContext(void * pContext
)
94 delete static_cast< ImplIso2022CnToUnicodeContext
* >(pContext
);
97 sal_Size
ImplConvertIso2022CnToUnicode(void const * pData
,
101 sal_Unicode
* pDestBuf
,
105 sal_Size
* pSrcCvtBytes
)
107 ImplDBCSToUniLeadTab
const * pGb2312Data
108 = static_cast< ImplIso2022CnConverterData
const * >(pData
)->
109 m_pGb2312ToUnicodeData
;
110 sal_uInt16
const * pCns116431992Data
111 = static_cast< ImplIso2022CnConverterData
const * >(pData
)->
112 m_pCns116431992ToUnicodeData
;
113 sal_Int32
const * pCns116431992RowOffsets
114 = static_cast< ImplIso2022CnConverterData
const * >(pData
)->
115 m_pCns116431992ToUnicodeRowOffsets
;
116 sal_Int32
const * pCns116431992PlaneOffsets
117 = static_cast< ImplIso2022CnConverterData
const * >(pData
)->
118 m_pCns116431992ToUnicodePlaneOffsets
;
119 ImplIso2022CnToUnicodeState eState
120 = IMPL_ISO_2022_CN_TO_UNICODE_STATE_ASCII
;
123 bool b116431
= false;
124 sal_uInt32 nInfo
= 0;
125 sal_Size nConverted
= 0;
126 sal_Unicode
* pDestBufPtr
= pDestBuf
;
127 sal_Unicode
* pDestBufEnd
= pDestBuf
+ nDestChars
;
131 eState
= static_cast< ImplIso2022CnToUnicodeContext
* >(pContext
)->m_eState
;
132 nRow
= static_cast< ImplIso2022CnToUnicodeContext
* >(pContext
)->m_nRow
;
133 bSo
= static_cast< ImplIso2022CnToUnicodeContext
* >(pContext
)->m_bSo
;
134 b116431
= static_cast< ImplIso2022CnToUnicodeContext
* >(pContext
)->m_b116431
;
137 for (; nConverted
< nSrcBytes
; ++nConverted
)
139 bool bUndefined
= true;
140 sal_uInt32 nChar
= *(sal_uChar
const *) pSrcBuf
++;
144 case IMPL_ISO_2022_CN_TO_UNICODE_STATE_ASCII
:
145 if (nChar
== 0x0E) // SO
148 eState
= IMPL_ISO_2022_CN_TO_UNICODE_STATE_SO
;
150 else if (nChar
== 0x1B) // ESC
151 eState
= IMPL_ISO_2022_CN_TO_UNICODE_STATE_ESC
;
152 else if (nChar
< 0x80)
153 if (pDestBufPtr
!= pDestBufEnd
)
154 *pDestBufPtr
++ = (sal_Unicode
) nChar
;
164 case IMPL_ISO_2022_CN_TO_UNICODE_STATE_SO
:
165 if (nChar
== 0x0F) // SI
168 eState
= IMPL_ISO_2022_CN_TO_UNICODE_STATE_ASCII
;
170 else if (nChar
== 0x1B) // ESC
171 eState
= IMPL_ISO_2022_CN_TO_UNICODE_STATE_ESC
;
172 else if (nChar
>= 0x21 && nChar
<= 0x7E)
175 eState
= IMPL_ISO_2022_CN_TO_UNICODE_STATE_SO_2
;
184 case IMPL_ISO_2022_CN_TO_UNICODE_STATE_SO_2
:
185 if (nChar
>= 0x21 && nChar
<= 0x7E)
193 sal_uInt16 nUnicode
= 0;
197 nFirst
= pGb2312Data
[nRow
].mnTrailStart
;
199 && nChar
<= pGb2312Data
[nRow
].mnTrailEnd
)
200 nUnicode
= pGb2312Data
[nRow
].
201 mpToUniTrailTab
[nChar
- nFirst
];
203 if (pDestBufPtr
!= pDestBufEnd
)
205 *pDestBufPtr
++ = (sal_Unicode
) nUnicode
;
206 eState
= IMPL_ISO_2022_CN_TO_UNICODE_STATE_SO
;
220 case IMPL_ISO_2022_CN_TO_UNICODE_STATE_116432
:
221 if (nChar
>= 0x21 && nChar
<= 0x7E)
224 eState
= IMPL_ISO_2022_CN_TO_UNICODE_STATE_116432_2
;
233 case IMPL_ISO_2022_CN_TO_UNICODE_STATE_116432_2
:
234 if (nChar
>= 0x21 && nChar
<= 0x7E)
246 case IMPL_ISO_2022_CN_TO_UNICODE_STATE_ESC
:
247 if (nChar
== 0x24) // $
248 eState
= IMPL_ISO_2022_CN_TO_UNICODE_STATE_ESC_DOLLAR
;
249 else if (nChar
== 0x4E) // N
250 eState
= IMPL_ISO_2022_CN_TO_UNICODE_STATE_116432
;
258 case IMPL_ISO_2022_CN_TO_UNICODE_STATE_ESC_DOLLAR
:
259 if (nChar
== 0x29) // )
260 eState
= IMPL_ISO_2022_CN_TO_UNICODE_STATE_ESC_DOLLAR_RPAREN
;
261 else if (nChar
== 0x2A) // *
263 = IMPL_ISO_2022_CN_TO_UNICODE_STATE_ESC_DOLLAR_ASTERISK
;
271 case IMPL_ISO_2022_CN_TO_UNICODE_STATE_ESC_DOLLAR_RPAREN
:
272 if (nChar
== 0x41) // A
275 eState
= bSo
? IMPL_ISO_2022_CN_TO_UNICODE_STATE_SO
:
276 IMPL_ISO_2022_CN_TO_UNICODE_STATE_ASCII
;
278 else if (nChar
== 0x47) // G
281 eState
= bSo
? IMPL_ISO_2022_CN_TO_UNICODE_STATE_SO
:
282 IMPL_ISO_2022_CN_TO_UNICODE_STATE_ASCII
;
291 case IMPL_ISO_2022_CN_TO_UNICODE_STATE_ESC_DOLLAR_ASTERISK
:
292 if (nChar
== 0x48) // H
293 eState
= bSo
? IMPL_ISO_2022_CN_TO_UNICODE_STATE_SO
:
294 IMPL_ISO_2022_CN_TO_UNICODE_STATE_ASCII
;
306 sal_Int32 nPlaneOffset
= pCns116431992PlaneOffsets
[nPlane
];
307 if (nPlaneOffset
== -1)
312 = pCns116431992RowOffsets
[nPlaneOffset
+ (nRow
- 0x21)];
317 sal_uInt32 nFirstLast
= pCns116431992Data
[nOffset
++];
318 sal_uInt32 nFirst
= nFirstLast
& 0xFF;
319 sal_uInt32 nLast
= nFirstLast
>> 8;
321 if (nChar
>= nFirst
&& nChar
<= nLast
)
324 = pCns116431992Data
[nOffset
+ (nChar
- nFirst
)];
325 if (nUnicode
== 0xFFFF)
327 else if (ImplIsHighSurrogate(nUnicode
))
328 if (pDestBufEnd
- pDestBufPtr
>= 2)
330 nOffset
+= nLast
- nFirst
+ 1;
331 nFirst
= pCns116431992Data
[nOffset
++];
332 *pDestBufPtr
++ = (sal_Unicode
) nUnicode
;
336 nOffset
+ (nChar
- nFirst
)];
341 if (pDestBufPtr
!= pDestBufEnd
)
342 *pDestBufPtr
++ = (sal_Unicode
) nUnicode
;
348 eState
= bSo
? IMPL_ISO_2022_CN_TO_UNICODE_STATE_SO
:
349 IMPL_ISO_2022_CN_TO_UNICODE_STATE_ASCII
;
356 switch (sal::detail::textenc::handleBadInputTextToUnicodeConversion(
357 bUndefined
, true, 0, nFlags
, &pDestBufPtr
, pDestBufEnd
,
360 case sal::detail::textenc::BAD_INPUT_STOP
:
361 eState
= IMPL_ISO_2022_CN_TO_UNICODE_STATE_ASCII
;
365 case sal::detail::textenc::BAD_INPUT_CONTINUE
:
366 eState
= IMPL_ISO_2022_CN_TO_UNICODE_STATE_ASCII
;
370 case sal::detail::textenc::BAD_INPUT_NO_OUTPUT
:
377 nInfo
|= RTL_TEXTTOUNICODE_INFO_DESTBUFFERTOSMALL
;
381 if (eState
> IMPL_ISO_2022_CN_TO_UNICODE_STATE_SO
382 && (nInfo
& (RTL_TEXTTOUNICODE_INFO_ERROR
383 | RTL_TEXTTOUNICODE_INFO_DESTBUFFERTOSMALL
))
386 if ((nFlags
& RTL_TEXTTOUNICODE_FLAGS_FLUSH
) == 0)
387 nInfo
|= RTL_TEXTTOUNICODE_INFO_SRCBUFFERTOSMALL
;
389 switch (sal::detail::textenc::handleBadInputTextToUnicodeConversion(
390 false, true, 0, nFlags
, &pDestBufPtr
, pDestBufEnd
,
393 case sal::detail::textenc::BAD_INPUT_STOP
:
394 case sal::detail::textenc::BAD_INPUT_CONTINUE
:
395 eState
= IMPL_ISO_2022_CN_TO_UNICODE_STATE_ASCII
;
399 case sal::detail::textenc::BAD_INPUT_NO_OUTPUT
:
400 nInfo
|= RTL_TEXTTOUNICODE_INFO_DESTBUFFERTOSMALL
;
407 static_cast< ImplIso2022CnToUnicodeContext
* >(pContext
)->m_eState
= eState
;
408 static_cast< ImplIso2022CnToUnicodeContext
* >(pContext
)->m_nRow
= nRow
;
409 static_cast< ImplIso2022CnToUnicodeContext
* >(pContext
)->m_bSo
= bSo
;
410 static_cast< ImplIso2022CnToUnicodeContext
* >(pContext
)->m_b116431
= b116431
;
415 *pSrcCvtBytes
= nConverted
;
417 return pDestBufPtr
- pDestBuf
;
420 void * ImplCreateUnicodeToIso2022CnContext(void)
422 ImplUnicodeToIso2022CnContext
* pContext
=
423 new ImplUnicodeToIso2022CnContext
;
424 pContext
->m_nHighSurrogate
= 0;
425 pContext
->m_eSoDesignator
= IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_NONE
;
426 pContext
->m_b116432Designator
= false;
427 pContext
->m_bSo
= false;
431 void ImplResetUnicodeToIso2022CnContext(void * pContext
)
435 static_cast< ImplUnicodeToIso2022CnContext
* >(pContext
)->m_nHighSurrogate
= 0;
436 static_cast< ImplUnicodeToIso2022CnContext
* >(pContext
)->m_eSoDesignator
437 = IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_NONE
;
438 static_cast< ImplUnicodeToIso2022CnContext
* >(pContext
)->m_b116432Designator
440 static_cast< ImplUnicodeToIso2022CnContext
* >(pContext
)->m_bSo
= false;
444 void ImplDestroyUnicodeToIso2022CnContext(void * pContext
)
446 delete static_cast< ImplUnicodeToIso2022CnContext
* >(pContext
);
449 static sal_uInt32
ImplIso2022CnTranslateTo2312(ImplUniToDBCSHighTab
const *
453 sal_uInt32 nIndex1
= nChar
>> 8;
456 sal_uInt32 nIndex2
= nChar
& 0xFF;
457 sal_uInt32 nFirst
= pGb2312Data
[nIndex1
].mnLowStart
;
458 if (nIndex2
>= nFirst
&& nIndex2
<= pGb2312Data
[nIndex1
].mnLowEnd
)
459 return pGb2312Data
[nIndex1
].mpToUniTrailTab
[nIndex2
- nFirst
]
466 ImplIso2022CnTranslateTo116431(sal_uInt8
const * pCns116431992Data
,
467 sal_Int32
const * pCns116431992PageOffsets
,
468 sal_Int32
const * pCns116431992PlaneOffsets
,
471 sal_Int32 nOffset
= pCns116431992PlaneOffsets
[nChar
>> 16];
477 nOffset
= pCns116431992PageOffsets
[nOffset
+ ((nChar
& 0xFF00) >> 8)];
480 nFirst
= pCns116431992Data
[nOffset
++];
481 nLast
= pCns116431992Data
[nOffset
++];
483 if (nChar
< nFirst
|| nChar
> nLast
)
485 nOffset
+= 3 * (nChar
- nFirst
);
486 nPlane
= pCns116431992Data
[nOffset
++];
489 return (0x20 + pCns116431992Data
[nOffset
]) << 8
490 | (0x20 + pCns116431992Data
[nOffset
+ 1]);
493 sal_Size
ImplConvertUnicodeToIso2022Cn(void const * pData
,
495 sal_Unicode
const * pSrcBuf
,
501 sal_Size
* pSrcCvtChars
)
503 ImplUniToDBCSHighTab
const * pGb2312Data
504 = static_cast< ImplIso2022CnConverterData
const * >(pData
)->
505 m_pUnicodeToGb2312Data
;
506 sal_uInt8
const * pCns116431992Data
507 = static_cast< ImplIso2022CnConverterData
const * >(pData
)->
508 m_pUnicodeToCns116431992Data
;
509 sal_Int32
const * pCns116431992PageOffsets
510 = static_cast< ImplIso2022CnConverterData
const * >(pData
)->
511 m_pUnicodeToCns116431992PageOffsets
;
512 sal_Int32
const * pCns116431992PlaneOffsets
513 = static_cast< ImplIso2022CnConverterData
const * >(pData
)->
514 m_pUnicodeToCns116431992PlaneOffsets
;
515 sal_Unicode nHighSurrogate
= 0;
516 ImplUnicodeToIso2022CnDesignator eSoDesignator
517 = IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_NONE
;
518 bool b116432Designator
= false;
520 sal_uInt32 nInfo
= 0;
521 sal_Size nConverted
= 0;
522 char * pDestBufPtr
= pDestBuf
;
523 char * pDestBufEnd
= pDestBuf
+ nDestBytes
;
529 = static_cast< ImplUnicodeToIso2022CnContext
* >(pContext
)->m_nHighSurrogate
;
531 = static_cast< ImplUnicodeToIso2022CnContext
* >(pContext
)->m_eSoDesignator
;
532 b116432Designator
= static_cast< ImplUnicodeToIso2022CnContext
* >(pContext
)->
534 bSo
= static_cast< ImplUnicodeToIso2022CnContext
* >(pContext
)->m_bSo
;
537 for (; nConverted
< nSrcChars
; ++nConverted
)
539 bool bUndefined
= true;
540 sal_uInt32 nChar
= *pSrcBuf
++;
541 if (nHighSurrogate
== 0)
543 if (ImplIsHighSurrogate(nChar
))
545 nHighSurrogate
= (sal_Unicode
) nChar
;
549 else if (ImplIsLowSurrogate(nChar
))
550 nChar
= ImplCombineSurrogates(nHighSurrogate
, nChar
);
557 if (ImplIsLowSurrogate(nChar
) || ImplIsNoncharacter(nChar
))
563 if (nChar
== 0x0A || nChar
== 0x0D) // LF, CR
567 if (pDestBufPtr
!= pDestBufEnd
)
569 *pDestBufPtr
++ = 0x0F; // SI
572 = IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_NONE
;
573 b116432Designator
= false;
578 if (pDestBufPtr
!= pDestBufEnd
)
579 *pDestBufPtr
++ = static_cast< char >(nChar
);
583 else if (nChar
== 0x0E || nChar
== 0x0F || nChar
== 0x1B)
585 else if (nChar
< 0x80)
589 if (pDestBufPtr
!= pDestBufEnd
)
591 *pDestBufPtr
++ = 0x0F; // SI
597 if (pDestBufPtr
!= pDestBufEnd
)
598 *pDestBufPtr
++ = static_cast< char >(nChar
);
604 sal_uInt32 nBytes
= 0;
605 ImplUnicodeToIso2022CnDesignator eNewDesignator
=
606 IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_NONE
;
607 switch (eSoDesignator
)
609 case IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_NONE
:
610 nBytes
= ImplIso2022CnTranslateTo2312(pGb2312Data
, nChar
);
614 = IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_2312
;
617 nBytes
= ImplIso2022CnTranslateTo116431(
619 pCns116431992PageOffsets
,
620 pCns116431992PlaneOffsets
,
625 = IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_116431
;
630 case IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_2312
:
631 nBytes
= ImplIso2022CnTranslateTo2312(pGb2312Data
, nChar
);
635 = IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_NONE
;
638 nBytes
= ImplIso2022CnTranslateTo116431(
640 pCns116431992PageOffsets
,
641 pCns116431992PlaneOffsets
,
646 = IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_116431
;
651 case IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_116431
:
652 nBytes
= ImplIso2022CnTranslateTo116431(
654 pCns116431992PageOffsets
,
655 pCns116431992PlaneOffsets
,
660 = IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_NONE
;
663 nBytes
= ImplIso2022CnTranslateTo2312(pGb2312Data
, nChar
);
667 = IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_2312
;
675 != IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_NONE
)
679 if (pDestBufPtr
!= pDestBufEnd
)
681 *pDestBufPtr
++ = 0x0F; // SI
687 if (pDestBufEnd
- pDestBufPtr
>= 4)
689 *pDestBufPtr
++ = 0x1B; // ESC
690 *pDestBufPtr
++ = 0x24; // $
691 *pDestBufPtr
++ = 0x29; // )
694 == IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_2312
?
696 eSoDesignator
= eNewDesignator
;
703 if (pDestBufPtr
!= pDestBufEnd
)
705 *pDestBufPtr
++ = 0x0E; // SO
711 if (pDestBufEnd
- pDestBufPtr
>= 4)
713 *pDestBufPtr
++ = static_cast< char >(nBytes
>> 8);
714 *pDestBufPtr
++ = static_cast< char >(nBytes
& 0xFF);
721 sal_Int32 nOffset
= pCns116431992PlaneOffsets
[nChar
>> 16];
728 = pCns116431992PageOffsets
[nOffset
729 + ((nChar
& 0xFF00) >> 8)];
732 nFirst
= pCns116431992Data
[nOffset
++];
733 nLast
= pCns116431992Data
[nOffset
++];
735 if (nChar
< nFirst
|| nChar
> nLast
)
737 nOffset
+= 3 * (nChar
- nFirst
);
738 nPlane
= pCns116431992Data
[nOffset
++];
741 if (!b116432Designator
)
743 if (pDestBufEnd
- pDestBufPtr
>= 4)
745 *pDestBufPtr
++ = 0x1B; // ESC
746 *pDestBufPtr
++ = 0x24; // $
747 *pDestBufPtr
++ = 0x2A; // *
748 *pDestBufPtr
++ = 0x48; // H
749 b116432Designator
= true;
754 if (pDestBufEnd
- pDestBufPtr
>= 4)
756 *pDestBufPtr
++ = 0x1B; // ESC
757 *pDestBufPtr
++ = 0x4E; // N
759 = static_cast< char >(0x20 + pCns116431992Data
[nOffset
++]);
761 = static_cast< char >(0x20 + pCns116431992Data
[nOffset
]);
771 switch (sal::detail::textenc::handleBadInputUnicodeToTextConversion(
772 bUndefined
, nChar
, nFlags
, &pDestBufPtr
, pDestBufEnd
,
773 &nInfo
, "\x0F" /* SI */, bSo
? 1 : 0, &bWritten
))
775 case sal::detail::textenc::BAD_INPUT_STOP
:
779 case sal::detail::textenc::BAD_INPUT_CONTINUE
:
785 case sal::detail::textenc::BAD_INPUT_NO_OUTPUT
:
792 nInfo
|= RTL_UNICODETOTEXT_INFO_DESTBUFFERTOSMALL
;
796 if ((nInfo
& (RTL_UNICODETOTEXT_INFO_ERROR
797 | RTL_UNICODETOTEXT_INFO_DESTBUFFERTOSMALL
))
801 if (nHighSurrogate
!= 0)
803 if ((nFlags
& RTL_UNICODETOTEXT_FLAGS_FLUSH
) != 0)
804 nInfo
|= RTL_UNICODETOTEXT_INFO_SRCBUFFERTOSMALL
;
806 switch (sal::detail::textenc::handleBadInputUnicodeToTextConversion(
807 false, 0, nFlags
, &pDestBufPtr
, pDestBufEnd
, &nInfo
,
808 "\x0F" /* SI */, bSo
? 1 : 0, &bWritten
))
810 case sal::detail::textenc::BAD_INPUT_STOP
:
815 case sal::detail::textenc::BAD_INPUT_CONTINUE
:
821 case sal::detail::textenc::BAD_INPUT_NO_OUTPUT
:
822 nInfo
|= RTL_UNICODETOTEXT_INFO_DESTBUFFERTOSMALL
;
826 if (bFlush
&& bSo
&& (nFlags
& RTL_UNICODETOTEXT_FLAGS_FLUSH
) != 0)
828 if (pDestBufPtr
!= pDestBufEnd
)
830 *pDestBufPtr
++ = 0x0F; // SI
834 nInfo
|= RTL_UNICODETOTEXT_INFO_DESTBUFFERTOSMALL
;
840 static_cast< ImplUnicodeToIso2022CnContext
* >(pContext
)->m_nHighSurrogate
842 static_cast< ImplUnicodeToIso2022CnContext
* >(pContext
)->m_eSoDesignator
844 static_cast< ImplUnicodeToIso2022CnContext
* >(pContext
)->m_b116432Designator
846 static_cast< ImplUnicodeToIso2022CnContext
* >(pContext
)->m_bSo
= bSo
;
851 *pSrcCvtChars
= nConverted
;
853 return pDestBufPtr
- pDestBuf
;
856 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */