1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 #include "convertiso2022cn.h"
30 #include "converter.h"
33 #include "rtl/alloc.h"
34 #include "rtl/textcvt.h"
35 #include "sal/types.h"
37 typedef enum /* order is important: */
39 IMPL_ISO_2022_CN_TO_UNICODE_STATE_ASCII
,
40 IMPL_ISO_2022_CN_TO_UNICODE_STATE_SO
,
41 IMPL_ISO_2022_CN_TO_UNICODE_STATE_SO_2
,
42 IMPL_ISO_2022_CN_TO_UNICODE_STATE_116432
,
43 IMPL_ISO_2022_CN_TO_UNICODE_STATE_116432_2
,
44 IMPL_ISO_2022_CN_TO_UNICODE_STATE_ESC
,
45 IMPL_ISO_2022_CN_TO_UNICODE_STATE_ESC_DOLLAR
,
46 IMPL_ISO_2022_CN_TO_UNICODE_STATE_ESC_DOLLAR_RPAREN
,
47 IMPL_ISO_2022_CN_TO_UNICODE_STATE_ESC_DOLLAR_ASTERISK
48 } ImplIso2022CnToUnicodeState
;
52 ImplIso2022CnToUnicodeState m_eState
;
56 } ImplIso2022CnToUnicodeContext
;
60 IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_NONE
,
61 IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_2312
,
62 IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_116431
63 } ImplUnicodeToIso2022CnDesignator
;
67 sal_Unicode m_nHighSurrogate
;
68 ImplUnicodeToIso2022CnDesignator m_eSoDesignator
;
69 sal_Bool m_b116432Designator
;
71 } ImplUnicodeToIso2022CnContext
;
73 void * ImplCreateIso2022CnToUnicodeContext(void)
76 = rtl_allocateMemory(sizeof (ImplIso2022CnToUnicodeContext
));
77 ((ImplIso2022CnToUnicodeContext
*) pContext
)->m_eState
78 = IMPL_ISO_2022_CN_TO_UNICODE_STATE_ASCII
;
79 ((ImplIso2022CnToUnicodeContext
*) pContext
)->m_bSo
= sal_False
;
80 ((ImplIso2022CnToUnicodeContext
*) pContext
)->m_b116431
= sal_False
;
84 void ImplResetIso2022CnToUnicodeContext(void * pContext
)
88 ((ImplIso2022CnToUnicodeContext
*) pContext
)->m_eState
89 = IMPL_ISO_2022_CN_TO_UNICODE_STATE_ASCII
;
90 ((ImplIso2022CnToUnicodeContext
*) pContext
)->m_bSo
= sal_False
;
91 ((ImplIso2022CnToUnicodeContext
*) pContext
)->m_b116431
= sal_False
;
95 sal_Size
ImplConvertIso2022CnToUnicode(ImplTextConverterData
const * pData
,
97 sal_Char
const * pSrcBuf
,
99 sal_Unicode
* pDestBuf
,
103 sal_Size
* pSrcCvtBytes
)
105 ImplDBCSToUniLeadTab
const * pGb2312Data
106 = ((ImplIso2022CnConverterData
const *) pData
)->
107 m_pGb2312ToUnicodeData
;
108 sal_uInt16
const * pCns116431992Data
109 = ((ImplIso2022CnConverterData
const *) pData
)->
110 m_pCns116431992ToUnicodeData
;
111 sal_Int32
const * pCns116431992RowOffsets
112 = ((ImplIso2022CnConverterData
const *) pData
)->
113 m_pCns116431992ToUnicodeRowOffsets
;
114 sal_Int32
const * pCns116431992PlaneOffsets
115 = ((ImplIso2022CnConverterData
const *) pData
)->
116 m_pCns116431992ToUnicodePlaneOffsets
;
117 ImplIso2022CnToUnicodeState eState
118 = IMPL_ISO_2022_CN_TO_UNICODE_STATE_ASCII
;
120 sal_Bool bSo
= sal_False
;
121 sal_Bool b116431
= sal_False
;
122 sal_uInt32 nInfo
= 0;
123 sal_Size nConverted
= 0;
124 sal_Unicode
* pDestBufPtr
= pDestBuf
;
125 sal_Unicode
* pDestBufEnd
= pDestBuf
+ nDestChars
;
129 eState
= ((ImplIso2022CnToUnicodeContext
*) pContext
)->m_eState
;
130 nRow
= ((ImplIso2022CnToUnicodeContext
*) pContext
)->m_nRow
;
131 bSo
= ((ImplIso2022CnToUnicodeContext
*) pContext
)->m_bSo
;
132 b116431
= ((ImplIso2022CnToUnicodeContext
*) pContext
)->m_b116431
;
135 for (; nConverted
< nSrcBytes
; ++nConverted
)
137 sal_Bool bUndefined
= sal_True
;
138 sal_uInt32 nChar
= *(sal_uChar
const *) pSrcBuf
++;
142 case IMPL_ISO_2022_CN_TO_UNICODE_STATE_ASCII
:
143 if (nChar
== 0x0E) /* SO */
146 eState
= IMPL_ISO_2022_CN_TO_UNICODE_STATE_SO
;
148 else if (nChar
== 0x1B) /* ESC */
149 eState
= IMPL_ISO_2022_CN_TO_UNICODE_STATE_ESC
;
150 else if (nChar
< 0x80)
151 if (pDestBufPtr
!= pDestBufEnd
)
152 *pDestBufPtr
++ = (sal_Unicode
) nChar
;
157 bUndefined
= sal_False
;
162 case IMPL_ISO_2022_CN_TO_UNICODE_STATE_SO
:
163 if (nChar
== 0x0F) /* SI */
166 eState
= IMPL_ISO_2022_CN_TO_UNICODE_STATE_ASCII
;
168 else if (nChar
== 0x1B) /* ESC */
169 eState
= IMPL_ISO_2022_CN_TO_UNICODE_STATE_ESC
;
170 else if (nChar
>= 0x21 && nChar
<= 0x7E)
173 eState
= IMPL_ISO_2022_CN_TO_UNICODE_STATE_SO_2
;
177 bUndefined
= sal_False
;
182 case IMPL_ISO_2022_CN_TO_UNICODE_STATE_SO_2
:
183 if (nChar
>= 0x21 && nChar
<= 0x7E)
191 sal_uInt16 nUnicode
= 0;
195 nFirst
= pGb2312Data
[nRow
].mnTrailStart
;
197 && nChar
<= pGb2312Data
[nRow
].mnTrailEnd
)
198 nUnicode
= pGb2312Data
[nRow
].
199 mpToUniTrailTab
[nChar
- nFirst
];
201 if (pDestBufPtr
!= pDestBufEnd
)
203 *pDestBufPtr
++ = (sal_Unicode
) nUnicode
;
204 eState
= IMPL_ISO_2022_CN_TO_UNICODE_STATE_SO
;
213 bUndefined
= sal_False
;
218 case IMPL_ISO_2022_CN_TO_UNICODE_STATE_116432
:
219 if (nChar
>= 0x21 && nChar
<= 0x7E)
222 eState
= IMPL_ISO_2022_CN_TO_UNICODE_STATE_116432_2
;
226 bUndefined
= sal_False
;
231 case IMPL_ISO_2022_CN_TO_UNICODE_STATE_116432_2
:
232 if (nChar
>= 0x21 && nChar
<= 0x7E)
239 bUndefined
= sal_False
;
244 case IMPL_ISO_2022_CN_TO_UNICODE_STATE_ESC
:
245 if (nChar
== 0x24) /* $ */
246 eState
= IMPL_ISO_2022_CN_TO_UNICODE_STATE_ESC_DOLLAR
;
247 else if (nChar
== 0x4E) /* N */
248 eState
= IMPL_ISO_2022_CN_TO_UNICODE_STATE_116432
;
251 bUndefined
= sal_False
;
256 case IMPL_ISO_2022_CN_TO_UNICODE_STATE_ESC_DOLLAR
:
257 if (nChar
== 0x29) /* ) */
258 eState
= IMPL_ISO_2022_CN_TO_UNICODE_STATE_ESC_DOLLAR_RPAREN
;
259 else if (nChar
== 0x2A) /* * */
261 = IMPL_ISO_2022_CN_TO_UNICODE_STATE_ESC_DOLLAR_ASTERISK
;
264 bUndefined
= sal_False
;
269 case IMPL_ISO_2022_CN_TO_UNICODE_STATE_ESC_DOLLAR_RPAREN
:
270 if (nChar
== 0x41) /* A */
273 eState
= bSo
? IMPL_ISO_2022_CN_TO_UNICODE_STATE_SO
:
274 IMPL_ISO_2022_CN_TO_UNICODE_STATE_ASCII
;
276 else if (nChar
== 0x47) /* G */
279 eState
= bSo
? IMPL_ISO_2022_CN_TO_UNICODE_STATE_SO
:
280 IMPL_ISO_2022_CN_TO_UNICODE_STATE_ASCII
;
284 bUndefined
= sal_False
;
289 case IMPL_ISO_2022_CN_TO_UNICODE_STATE_ESC_DOLLAR_ASTERISK
:
290 if (nChar
== 0x48) /* H */
291 eState
= bSo
? IMPL_ISO_2022_CN_TO_UNICODE_STATE_SO
:
292 IMPL_ISO_2022_CN_TO_UNICODE_STATE_ASCII
;
295 bUndefined
= sal_False
;
304 sal_Int32 nPlaneOffset
= pCns116431992PlaneOffsets
[nPlane
];
305 if (nPlaneOffset
== -1)
310 = pCns116431992RowOffsets
[nPlaneOffset
+ (nRow
- 0x21)];
315 sal_uInt32 nFirstLast
= pCns116431992Data
[nOffset
++];
316 sal_uInt32 nFirst
= nFirstLast
& 0xFF;
317 sal_uInt32 nLast
= nFirstLast
>> 8;
319 if (nChar
>= nFirst
&& nChar
<= nLast
)
322 = pCns116431992Data
[nOffset
+ (nChar
- nFirst
)];
323 if (nUnicode
== 0xFFFF)
325 else if (ImplIsHighSurrogate(nUnicode
))
326 if (pDestBufEnd
- pDestBufPtr
>= 2)
328 nOffset
+= nLast
- nFirst
+ 1;
329 nFirst
= pCns116431992Data
[nOffset
++];
330 *pDestBufPtr
++ = (sal_Unicode
) nUnicode
;
334 nOffset
+ (nChar
- nFirst
)];
339 if (pDestBufPtr
!= pDestBufEnd
)
340 *pDestBufPtr
++ = (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 (ImplHandleBadInputTextToUnicodeConversion(
355 bUndefined
, sal_True
, 0, nFlags
, &pDestBufPtr
, pDestBufEnd
,
358 case IMPL_BAD_INPUT_STOP
:
359 eState
= IMPL_ISO_2022_CN_TO_UNICODE_STATE_ASCII
;
363 case IMPL_BAD_INPUT_CONTINUE
:
364 eState
= IMPL_ISO_2022_CN_TO_UNICODE_STATE_ASCII
;
368 case IMPL_BAD_INPUT_NO_OUTPUT
:
375 nInfo
|= RTL_TEXTTOUNICODE_INFO_DESTBUFFERTOSMALL
;
379 if (eState
> IMPL_ISO_2022_CN_TO_UNICODE_STATE_SO
380 && (nInfo
& (RTL_TEXTTOUNICODE_INFO_ERROR
381 | RTL_TEXTTOUNICODE_INFO_DESTBUFFERTOSMALL
))
384 if ((nFlags
& RTL_TEXTTOUNICODE_FLAGS_FLUSH
) == 0)
385 nInfo
|= RTL_TEXTTOUNICODE_INFO_SRCBUFFERTOSMALL
;
387 switch (ImplHandleBadInputTextToUnicodeConversion(
388 sal_False
, sal_True
, 0, nFlags
, &pDestBufPtr
, pDestBufEnd
,
391 case IMPL_BAD_INPUT_STOP
:
392 case IMPL_BAD_INPUT_CONTINUE
:
393 eState
= IMPL_ISO_2022_CN_TO_UNICODE_STATE_ASCII
;
397 case IMPL_BAD_INPUT_NO_OUTPUT
:
398 nInfo
|= RTL_TEXTTOUNICODE_INFO_DESTBUFFERTOSMALL
;
405 ((ImplIso2022CnToUnicodeContext
*) pContext
)->m_eState
= eState
;
406 ((ImplIso2022CnToUnicodeContext
*) pContext
)->m_nRow
= nRow
;
407 ((ImplIso2022CnToUnicodeContext
*) pContext
)->m_bSo
= bSo
;
408 ((ImplIso2022CnToUnicodeContext
*) pContext
)->m_b116431
= b116431
;
413 *pSrcCvtBytes
= nConverted
;
415 return pDestBufPtr
- pDestBuf
;
418 void * ImplCreateUnicodeToIso2022CnContext(void)
421 = rtl_allocateMemory(sizeof (ImplUnicodeToIso2022CnContext
));
422 ((ImplUnicodeToIso2022CnContext
*) pContext
)->m_nHighSurrogate
= 0;
423 ((ImplUnicodeToIso2022CnContext
*) pContext
)->m_eSoDesignator
424 = IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_NONE
;
425 ((ImplUnicodeToIso2022CnContext
*) pContext
)->m_b116432Designator
427 ((ImplUnicodeToIso2022CnContext
*) pContext
)->m_bSo
= sal_False
;
431 void ImplResetUnicodeToIso2022CnContext(void * pContext
)
435 ((ImplUnicodeToIso2022CnContext
*) pContext
)->m_nHighSurrogate
= 0;
436 ((ImplUnicodeToIso2022CnContext
*) pContext
)->m_eSoDesignator
437 = IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_NONE
;
438 ((ImplUnicodeToIso2022CnContext
*) pContext
)->m_b116432Designator
440 ((ImplUnicodeToIso2022CnContext
*) pContext
)->m_bSo
= sal_False
;
444 static sal_uInt32
ImplIso2022CnTranslateTo2312(ImplUniToDBCSHighTab
const *
448 sal_uInt32 nIndex1
= nChar
>> 8;
451 sal_uInt32 nIndex2
= nChar
& 0xFF;
452 sal_uInt32 nFirst
= pGb2312Data
[nIndex1
].mnLowStart
;
453 if (nIndex2
>= nFirst
&& nIndex2
<= pGb2312Data
[nIndex1
].mnLowEnd
)
454 return pGb2312Data
[nIndex1
].mpToUniTrailTab
[nIndex2
- nFirst
]
461 ImplIso2022CnTranslateTo116431(sal_uInt8
const * pCns116431992Data
,
462 sal_Int32
const * pCns116431992PageOffsets
,
463 sal_Int32
const * pCns116431992PlaneOffsets
,
466 sal_Int32 nOffset
= pCns116431992PlaneOffsets
[nChar
>> 16];
472 nOffset
= pCns116431992PageOffsets
[nOffset
+ ((nChar
& 0xFF00) >> 8)];
475 nFirst
= pCns116431992Data
[nOffset
++];
476 nLast
= pCns116431992Data
[nOffset
++];
478 if (nChar
< nFirst
|| nChar
> nLast
)
480 nOffset
+= 3 * (nChar
- nFirst
);
481 nPlane
= pCns116431992Data
[nOffset
++];
484 return (0x20 + pCns116431992Data
[nOffset
]) << 8
485 | (0x20 + pCns116431992Data
[nOffset
+ 1]);
488 sal_Size
ImplConvertUnicodeToIso2022Cn(ImplTextConverterData
const * pData
,
490 sal_Unicode
const * pSrcBuf
,
496 sal_Size
* pSrcCvtChars
)
498 ImplUniToDBCSHighTab
const * pGb2312Data
499 = ((ImplIso2022CnConverterData
const *) pData
)->
500 m_pUnicodeToGb2312Data
;
501 sal_uInt8
const * pCns116431992Data
502 = ((ImplIso2022CnConverterData
const *) pData
)->
503 m_pUnicodeToCns116431992Data
;
504 sal_Int32
const * pCns116431992PageOffsets
505 = ((ImplIso2022CnConverterData
const *) pData
)->
506 m_pUnicodeToCns116431992PageOffsets
;
507 sal_Int32
const * pCns116431992PlaneOffsets
508 = ((ImplIso2022CnConverterData
const *) pData
)->
509 m_pUnicodeToCns116431992PlaneOffsets
;
510 sal_Unicode nHighSurrogate
= 0;
511 ImplUnicodeToIso2022CnDesignator eSoDesignator
512 = IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_NONE
;
513 sal_Bool b116432Designator
= sal_False
;
514 sal_Bool bSo
= sal_False
;
515 sal_uInt32 nInfo
= 0;
516 sal_Size nConverted
= 0;
517 sal_Char
* pDestBufPtr
= pDestBuf
;
518 sal_Char
* pDestBufEnd
= pDestBuf
+ nDestBytes
;
524 = ((ImplUnicodeToIso2022CnContext
*) pContext
)->m_nHighSurrogate
;
526 = ((ImplUnicodeToIso2022CnContext
*) pContext
)->m_eSoDesignator
;
527 b116432Designator
= ((ImplUnicodeToIso2022CnContext
*) pContext
)->
529 bSo
= ((ImplUnicodeToIso2022CnContext
*) pContext
)->m_bSo
;
532 for (; nConverted
< nSrcChars
; ++nConverted
)
534 sal_Bool bUndefined
= sal_True
;
535 sal_uInt32 nChar
= *pSrcBuf
++;
536 if (nHighSurrogate
== 0)
538 if (ImplIsHighSurrogate(nChar
))
540 nHighSurrogate
= (sal_Unicode
) nChar
;
544 else if (ImplIsLowSurrogate(nChar
))
545 nChar
= ImplCombineSurrogates(nHighSurrogate
, nChar
);
548 bUndefined
= sal_False
;
552 if (ImplIsLowSurrogate(nChar
) || ImplIsNoncharacter(nChar
))
554 bUndefined
= sal_False
;
558 if (nChar
== 0x0A || nChar
== 0x0D) /* LF, CR */
562 if (pDestBufPtr
!= pDestBufEnd
)
564 *pDestBufPtr
++ = 0x0F; /* SI */
567 = IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_NONE
;
568 b116432Designator
= sal_False
;
573 if (pDestBufPtr
!= pDestBufEnd
)
574 *pDestBufPtr
++ = (sal_Char
) nChar
;
578 else if (nChar
== 0x0E || nChar
== 0x0F || nChar
== 0x1B)
580 else if (nChar
< 0x80)
584 if (pDestBufPtr
!= pDestBufEnd
)
586 *pDestBufPtr
++ = 0x0F; /* SI */
592 if (pDestBufPtr
!= pDestBufEnd
)
593 *pDestBufPtr
++ = (sal_Char
) nChar
;
599 sal_uInt32 nBytes
= 0;
600 ImplUnicodeToIso2022CnDesignator eNewDesignator
=
601 IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_NONE
;
602 switch (eSoDesignator
)
604 case IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_NONE
:
605 nBytes
= ImplIso2022CnTranslateTo2312(pGb2312Data
, nChar
);
609 = IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_2312
;
612 nBytes
= ImplIso2022CnTranslateTo116431(
614 pCns116431992PageOffsets
,
615 pCns116431992PlaneOffsets
,
620 = IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_116431
;
625 case IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_2312
:
626 nBytes
= ImplIso2022CnTranslateTo2312(pGb2312Data
, nChar
);
630 = IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_NONE
;
633 nBytes
= ImplIso2022CnTranslateTo116431(
635 pCns116431992PageOffsets
,
636 pCns116431992PlaneOffsets
,
641 = IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_116431
;
646 case IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_116431
:
647 nBytes
= ImplIso2022CnTranslateTo116431(
649 pCns116431992PageOffsets
,
650 pCns116431992PlaneOffsets
,
655 = IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_NONE
;
658 nBytes
= ImplIso2022CnTranslateTo2312(pGb2312Data
, nChar
);
662 = IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_2312
;
670 != IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_NONE
)
674 if (pDestBufPtr
!= pDestBufEnd
)
676 *pDestBufPtr
++ = 0x0F; /* SI */
682 if (pDestBufEnd
- pDestBufPtr
>= 4)
684 *pDestBufPtr
++ = 0x1B; /* ESC */
685 *pDestBufPtr
++ = 0x24; /* $ */
686 *pDestBufPtr
++ = 0x29; /* ) */
689 == IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_2312
?
690 0x41 : 0x47; /* A, G */
691 eSoDesignator
= eNewDesignator
;
698 if (pDestBufPtr
!= pDestBufEnd
)
700 *pDestBufPtr
++ = 0x0E; /* SO */
706 if (pDestBufEnd
- pDestBufPtr
>= 4)
708 *pDestBufPtr
++ = (sal_Char
) (nBytes
>> 8);
709 *pDestBufPtr
++ = (sal_Char
) (nBytes
& 0xFF);
716 sal_Int32 nOffset
= pCns116431992PlaneOffsets
[nChar
>> 16];
723 = pCns116431992PageOffsets
[nOffset
724 + ((nChar
& 0xFF00) >> 8)];
727 nFirst
= pCns116431992Data
[nOffset
++];
728 nLast
= pCns116431992Data
[nOffset
++];
730 if (nChar
< nFirst
|| nChar
> nLast
)
732 nOffset
+= 3 * (nChar
- nFirst
);
733 nPlane
= pCns116431992Data
[nOffset
++];
736 if (!b116432Designator
)
738 if (pDestBufEnd
- pDestBufPtr
>= 4)
740 *pDestBufPtr
++ = 0x1B; /* ESC */
741 *pDestBufPtr
++ = 0x24; /* $ */
742 *pDestBufPtr
++ = 0x2A; /* * */
743 *pDestBufPtr
++ = 0x48; /* H */
744 b116432Designator
= sal_True
;
749 if (pDestBufEnd
- pDestBufPtr
>= 4)
751 *pDestBufPtr
++ = 0x1B; /* ESC */
752 *pDestBufPtr
++ = 0x4E; /* N */
754 = (sal_Char
) (0x20 + pCns116431992Data
[nOffset
++]);
756 = (sal_Char
) (0x20 + pCns116431992Data
[nOffset
]);
766 switch (ImplHandleBadInputUnicodeToTextConversion(bUndefined
,
776 case IMPL_BAD_INPUT_STOP
:
780 case IMPL_BAD_INPUT_CONTINUE
:
786 case IMPL_BAD_INPUT_NO_OUTPUT
:
793 nInfo
|= RTL_UNICODETOTEXT_INFO_DESTBUFFERTOSMALL
;
797 if ((nInfo
& (RTL_UNICODETOTEXT_INFO_ERROR
798 | RTL_UNICODETOTEXT_INFO_DESTBUFFERTOSMALL
))
801 sal_Bool bFlush
= sal_True
;
802 if (nHighSurrogate
!= 0)
804 if ((nFlags
& RTL_UNICODETOTEXT_FLAGS_FLUSH
) != 0)
805 nInfo
|= RTL_UNICODETOTEXT_INFO_SRCBUFFERTOSMALL
;
807 switch (ImplHandleBadInputUnicodeToTextConversion(
818 case IMPL_BAD_INPUT_STOP
:
823 case IMPL_BAD_INPUT_CONTINUE
:
829 case IMPL_BAD_INPUT_NO_OUTPUT
:
830 nInfo
|= RTL_UNICODETOTEXT_INFO_DESTBUFFERTOSMALL
;
834 if (bFlush
&& bSo
&& (nFlags
& RTL_UNICODETOTEXT_FLAGS_FLUSH
) != 0)
836 if (pDestBufPtr
!= pDestBufEnd
)
838 *pDestBufPtr
++ = 0x0F; /* SI */
842 nInfo
|= RTL_UNICODETOTEXT_INFO_DESTBUFFERTOSMALL
;
848 ((ImplUnicodeToIso2022CnContext
*) pContext
)->m_nHighSurrogate
850 ((ImplUnicodeToIso2022CnContext
*) pContext
)->m_eSoDesignator
852 ((ImplUnicodeToIso2022CnContext
*) pContext
)->m_b116432Designator
854 ((ImplUnicodeToIso2022CnContext
*) pContext
)->m_bSo
= bSo
;
859 *pSrcCvtChars
= nConverted
;
861 return pDestBufPtr
- pDestBuf
;