1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: convertiso2022cn.c,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #include "convertiso2022cn.h"
33 #include "converter.h"
36 #include "rtl/alloc.h"
37 #include "rtl/textcvt.h"
38 #include "sal/types.h"
40 typedef enum /* order is important: */
42 IMPL_ISO_2022_CN_TO_UNICODE_STATE_ASCII
,
43 IMPL_ISO_2022_CN_TO_UNICODE_STATE_SO
,
44 IMPL_ISO_2022_CN_TO_UNICODE_STATE_SO_2
,
45 IMPL_ISO_2022_CN_TO_UNICODE_STATE_116432
,
46 IMPL_ISO_2022_CN_TO_UNICODE_STATE_116432_2
,
47 IMPL_ISO_2022_CN_TO_UNICODE_STATE_ESC
,
48 IMPL_ISO_2022_CN_TO_UNICODE_STATE_ESC_DOLLAR
,
49 IMPL_ISO_2022_CN_TO_UNICODE_STATE_ESC_DOLLAR_RPAREN
,
50 IMPL_ISO_2022_CN_TO_UNICODE_STATE_ESC_DOLLAR_ASTERISK
51 } ImplIso2022CnToUnicodeState
;
55 ImplIso2022CnToUnicodeState m_eState
;
59 } ImplIso2022CnToUnicodeContext
;
63 IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_NONE
,
64 IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_2312
,
65 IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_116431
66 } ImplUnicodeToIso2022CnDesignator
;
70 sal_Unicode m_nHighSurrogate
;
71 ImplUnicodeToIso2022CnDesignator m_eSoDesignator
;
72 sal_Bool m_b116432Designator
;
74 } ImplUnicodeToIso2022CnContext
;
76 void * ImplCreateIso2022CnToUnicodeContext(void)
79 = rtl_allocateMemory(sizeof (ImplIso2022CnToUnicodeContext
));
80 ((ImplIso2022CnToUnicodeContext
*) pContext
)->m_eState
81 = IMPL_ISO_2022_CN_TO_UNICODE_STATE_ASCII
;
82 ((ImplIso2022CnToUnicodeContext
*) pContext
)->m_bSo
= sal_False
;
83 ((ImplIso2022CnToUnicodeContext
*) pContext
)->m_b116431
= sal_False
;
87 void ImplResetIso2022CnToUnicodeContext(void * pContext
)
91 ((ImplIso2022CnToUnicodeContext
*) pContext
)->m_eState
92 = IMPL_ISO_2022_CN_TO_UNICODE_STATE_ASCII
;
93 ((ImplIso2022CnToUnicodeContext
*) pContext
)->m_bSo
= sal_False
;
94 ((ImplIso2022CnToUnicodeContext
*) pContext
)->m_b116431
= sal_False
;
98 sal_Size
ImplConvertIso2022CnToUnicode(ImplTextConverterData
const * pData
,
100 sal_Char
const * pSrcBuf
,
102 sal_Unicode
* pDestBuf
,
106 sal_Size
* pSrcCvtBytes
)
108 ImplDBCSToUniLeadTab
const * pGb2312Data
109 = ((ImplIso2022CnConverterData
const *) pData
)->
110 m_pGb2312ToUnicodeData
;
111 sal_uInt16
const * pCns116431992Data
112 = ((ImplIso2022CnConverterData
const *) pData
)->
113 m_pCns116431992ToUnicodeData
;
114 sal_Int32
const * pCns116431992RowOffsets
115 = ((ImplIso2022CnConverterData
const *) pData
)->
116 m_pCns116431992ToUnicodeRowOffsets
;
117 sal_Int32
const * pCns116431992PlaneOffsets
118 = ((ImplIso2022CnConverterData
const *) pData
)->
119 m_pCns116431992ToUnicodePlaneOffsets
;
120 ImplIso2022CnToUnicodeState eState
121 = IMPL_ISO_2022_CN_TO_UNICODE_STATE_ASCII
;
123 sal_Bool bSo
= sal_False
;
124 sal_Bool b116431
= sal_False
;
125 sal_uInt32 nInfo
= 0;
126 sal_Size nConverted
= 0;
127 sal_Unicode
* pDestBufPtr
= pDestBuf
;
128 sal_Unicode
* pDestBufEnd
= pDestBuf
+ nDestChars
;
132 eState
= ((ImplIso2022CnToUnicodeContext
*) pContext
)->m_eState
;
133 nRow
= ((ImplIso2022CnToUnicodeContext
*) pContext
)->m_nRow
;
134 bSo
= ((ImplIso2022CnToUnicodeContext
*) pContext
)->m_bSo
;
135 b116431
= ((ImplIso2022CnToUnicodeContext
*) pContext
)->m_b116431
;
138 for (; nConverted
< nSrcBytes
; ++nConverted
)
140 sal_Bool bUndefined
= sal_True
;
141 sal_uInt32 nChar
= *(sal_uChar
const *) pSrcBuf
++;
145 case IMPL_ISO_2022_CN_TO_UNICODE_STATE_ASCII
:
146 if (nChar
== 0x0E) /* SO */
149 eState
= IMPL_ISO_2022_CN_TO_UNICODE_STATE_SO
;
151 else if (nChar
== 0x1B) /* ESC */
152 eState
= IMPL_ISO_2022_CN_TO_UNICODE_STATE_ESC
;
153 else if (nChar
< 0x80)
154 if (pDestBufPtr
!= pDestBufEnd
)
155 *pDestBufPtr
++ = (sal_Unicode
) nChar
;
160 bUndefined
= sal_False
;
165 case IMPL_ISO_2022_CN_TO_UNICODE_STATE_SO
:
166 if (nChar
== 0x0F) /* SI */
169 eState
= IMPL_ISO_2022_CN_TO_UNICODE_STATE_ASCII
;
171 else if (nChar
== 0x1B) /* ESC */
172 eState
= IMPL_ISO_2022_CN_TO_UNICODE_STATE_ESC
;
173 else if (nChar
>= 0x21 && nChar
<= 0x7E)
176 eState
= IMPL_ISO_2022_CN_TO_UNICODE_STATE_SO_2
;
180 bUndefined
= sal_False
;
185 case IMPL_ISO_2022_CN_TO_UNICODE_STATE_SO_2
:
186 if (nChar
>= 0x21 && nChar
<= 0x7E)
194 sal_uInt16 nUnicode
= 0;
198 nFirst
= pGb2312Data
[nRow
].mnTrailStart
;
200 && nChar
<= pGb2312Data
[nRow
].mnTrailEnd
)
201 nUnicode
= pGb2312Data
[nRow
].
202 mpToUniTrailTab
[nChar
- nFirst
];
204 if (pDestBufPtr
!= pDestBufEnd
)
206 *pDestBufPtr
++ = (sal_Unicode
) nUnicode
;
207 eState
= IMPL_ISO_2022_CN_TO_UNICODE_STATE_SO
;
216 bUndefined
= sal_False
;
221 case IMPL_ISO_2022_CN_TO_UNICODE_STATE_116432
:
222 if (nChar
>= 0x21 && nChar
<= 0x7E)
225 eState
= IMPL_ISO_2022_CN_TO_UNICODE_STATE_116432_2
;
229 bUndefined
= sal_False
;
234 case IMPL_ISO_2022_CN_TO_UNICODE_STATE_116432_2
:
235 if (nChar
>= 0x21 && nChar
<= 0x7E)
242 bUndefined
= sal_False
;
247 case IMPL_ISO_2022_CN_TO_UNICODE_STATE_ESC
:
248 if (nChar
== 0x24) /* $ */
249 eState
= IMPL_ISO_2022_CN_TO_UNICODE_STATE_ESC_DOLLAR
;
250 else if (nChar
== 0x4E) /* N */
251 eState
= IMPL_ISO_2022_CN_TO_UNICODE_STATE_116432
;
254 bUndefined
= sal_False
;
259 case IMPL_ISO_2022_CN_TO_UNICODE_STATE_ESC_DOLLAR
:
260 if (nChar
== 0x29) /* ) */
261 eState
= IMPL_ISO_2022_CN_TO_UNICODE_STATE_ESC_DOLLAR_RPAREN
;
262 else if (nChar
== 0x2A) /* * */
264 = IMPL_ISO_2022_CN_TO_UNICODE_STATE_ESC_DOLLAR_ASTERISK
;
267 bUndefined
= sal_False
;
272 case IMPL_ISO_2022_CN_TO_UNICODE_STATE_ESC_DOLLAR_RPAREN
:
273 if (nChar
== 0x41) /* A */
276 eState
= bSo
? IMPL_ISO_2022_CN_TO_UNICODE_STATE_SO
:
277 IMPL_ISO_2022_CN_TO_UNICODE_STATE_ASCII
;
279 else if (nChar
== 0x47) /* G */
282 eState
= bSo
? IMPL_ISO_2022_CN_TO_UNICODE_STATE_SO
:
283 IMPL_ISO_2022_CN_TO_UNICODE_STATE_ASCII
;
287 bUndefined
= sal_False
;
292 case IMPL_ISO_2022_CN_TO_UNICODE_STATE_ESC_DOLLAR_ASTERISK
:
293 if (nChar
== 0x48) /* H */
294 eState
= bSo
? IMPL_ISO_2022_CN_TO_UNICODE_STATE_SO
:
295 IMPL_ISO_2022_CN_TO_UNICODE_STATE_ASCII
;
298 bUndefined
= sal_False
;
307 sal_Int32 nPlaneOffset
= pCns116431992PlaneOffsets
[nPlane
];
308 if (nPlaneOffset
== -1)
313 = pCns116431992RowOffsets
[nPlaneOffset
+ (nRow
- 0x21)];
318 sal_uInt32 nFirstLast
= pCns116431992Data
[nOffset
++];
319 sal_uInt32 nFirst
= nFirstLast
& 0xFF;
320 sal_uInt32 nLast
= nFirstLast
>> 8;
322 if (nChar
>= nFirst
&& nChar
<= nLast
)
325 = pCns116431992Data
[nOffset
+ (nChar
- nFirst
)];
326 if (nUnicode
== 0xFFFF)
328 else if (ImplIsHighSurrogate(nUnicode
))
329 if (pDestBufEnd
- pDestBufPtr
>= 2)
331 nOffset
+= nLast
- nFirst
+ 1;
332 nFirst
= pCns116431992Data
[nOffset
++];
333 *pDestBufPtr
++ = (sal_Unicode
) nUnicode
;
337 nOffset
+ (nChar
- nFirst
)];
342 if (pDestBufPtr
!= pDestBufEnd
)
343 *pDestBufPtr
++ = (sal_Unicode
) nUnicode
;
349 eState
= bSo
? IMPL_ISO_2022_CN_TO_UNICODE_STATE_SO
:
350 IMPL_ISO_2022_CN_TO_UNICODE_STATE_ASCII
;
357 switch (ImplHandleBadInputTextToUnicodeConversion(
358 bUndefined
, sal_True
, 0, nFlags
, &pDestBufPtr
, pDestBufEnd
,
361 case IMPL_BAD_INPUT_STOP
:
362 eState
= IMPL_ISO_2022_CN_TO_UNICODE_STATE_ASCII
;
366 case IMPL_BAD_INPUT_CONTINUE
:
367 eState
= IMPL_ISO_2022_CN_TO_UNICODE_STATE_ASCII
;
371 case IMPL_BAD_INPUT_NO_OUTPUT
:
378 nInfo
|= RTL_TEXTTOUNICODE_INFO_DESTBUFFERTOSMALL
;
382 if (eState
> IMPL_ISO_2022_CN_TO_UNICODE_STATE_SO
383 && (nInfo
& (RTL_TEXTTOUNICODE_INFO_ERROR
384 | RTL_TEXTTOUNICODE_INFO_DESTBUFFERTOSMALL
))
387 if ((nFlags
& RTL_TEXTTOUNICODE_FLAGS_FLUSH
) == 0)
388 nInfo
|= RTL_TEXTTOUNICODE_INFO_SRCBUFFERTOSMALL
;
390 switch (ImplHandleBadInputTextToUnicodeConversion(
391 sal_False
, sal_True
, 0, nFlags
, &pDestBufPtr
, pDestBufEnd
,
394 case IMPL_BAD_INPUT_STOP
:
395 case IMPL_BAD_INPUT_CONTINUE
:
396 eState
= IMPL_ISO_2022_CN_TO_UNICODE_STATE_ASCII
;
400 case IMPL_BAD_INPUT_NO_OUTPUT
:
401 nInfo
|= RTL_TEXTTOUNICODE_INFO_DESTBUFFERTOSMALL
;
408 ((ImplIso2022CnToUnicodeContext
*) pContext
)->m_eState
= eState
;
409 ((ImplIso2022CnToUnicodeContext
*) pContext
)->m_nRow
= nRow
;
410 ((ImplIso2022CnToUnicodeContext
*) pContext
)->m_bSo
= bSo
;
411 ((ImplIso2022CnToUnicodeContext
*) pContext
)->m_b116431
= b116431
;
416 *pSrcCvtBytes
= nConverted
;
418 return pDestBufPtr
- pDestBuf
;
421 void * ImplCreateUnicodeToIso2022CnContext(void)
424 = rtl_allocateMemory(sizeof (ImplUnicodeToIso2022CnContext
));
425 ((ImplUnicodeToIso2022CnContext
*) pContext
)->m_nHighSurrogate
= 0;
426 ((ImplUnicodeToIso2022CnContext
*) pContext
)->m_eSoDesignator
427 = IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_NONE
;
428 ((ImplUnicodeToIso2022CnContext
*) pContext
)->m_b116432Designator
430 ((ImplUnicodeToIso2022CnContext
*) pContext
)->m_bSo
= sal_False
;
434 void ImplResetUnicodeToIso2022CnContext(void * pContext
)
438 ((ImplUnicodeToIso2022CnContext
*) pContext
)->m_nHighSurrogate
= 0;
439 ((ImplUnicodeToIso2022CnContext
*) pContext
)->m_eSoDesignator
440 = IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_NONE
;
441 ((ImplUnicodeToIso2022CnContext
*) pContext
)->m_b116432Designator
443 ((ImplUnicodeToIso2022CnContext
*) pContext
)->m_bSo
= sal_False
;
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(ImplTextConverterData
const * pData
,
493 sal_Unicode
const * pSrcBuf
,
499 sal_Size
* pSrcCvtChars
)
501 ImplUniToDBCSHighTab
const * pGb2312Data
502 = ((ImplIso2022CnConverterData
const *) pData
)->
503 m_pUnicodeToGb2312Data
;
504 sal_uInt8
const * pCns116431992Data
505 = ((ImplIso2022CnConverterData
const *) pData
)->
506 m_pUnicodeToCns116431992Data
;
507 sal_Int32
const * pCns116431992PageOffsets
508 = ((ImplIso2022CnConverterData
const *) pData
)->
509 m_pUnicodeToCns116431992PageOffsets
;
510 sal_Int32
const * pCns116431992PlaneOffsets
511 = ((ImplIso2022CnConverterData
const *) pData
)->
512 m_pUnicodeToCns116431992PlaneOffsets
;
513 sal_Unicode nHighSurrogate
= 0;
514 ImplUnicodeToIso2022CnDesignator eSoDesignator
515 = IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_NONE
;
516 sal_Bool b116432Designator
= sal_False
;
517 sal_Bool bSo
= sal_False
;
518 sal_uInt32 nInfo
= 0;
519 sal_Size nConverted
= 0;
520 sal_Char
* pDestBufPtr
= pDestBuf
;
521 sal_Char
* pDestBufEnd
= pDestBuf
+ nDestBytes
;
527 = ((ImplUnicodeToIso2022CnContext
*) pContext
)->m_nHighSurrogate
;
529 = ((ImplUnicodeToIso2022CnContext
*) pContext
)->m_eSoDesignator
;
530 b116432Designator
= ((ImplUnicodeToIso2022CnContext
*) pContext
)->
532 bSo
= ((ImplUnicodeToIso2022CnContext
*) pContext
)->m_bSo
;
535 for (; nConverted
< nSrcChars
; ++nConverted
)
537 sal_Bool bUndefined
= sal_True
;
538 sal_uInt32 nChar
= *pSrcBuf
++;
539 if (nHighSurrogate
== 0)
541 if (ImplIsHighSurrogate(nChar
))
543 nHighSurrogate
= (sal_Unicode
) nChar
;
547 else if (ImplIsLowSurrogate(nChar
))
548 nChar
= ImplCombineSurrogates(nHighSurrogate
, nChar
);
551 bUndefined
= sal_False
;
555 if (ImplIsLowSurrogate(nChar
) || ImplIsNoncharacter(nChar
))
557 bUndefined
= sal_False
;
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
= sal_False
;
576 if (pDestBufPtr
!= pDestBufEnd
)
577 *pDestBufPtr
++ = (sal_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
++ = (sal_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
?
693 0x41 : 0x47; /* A, G */
694 eSoDesignator
= eNewDesignator
;
701 if (pDestBufPtr
!= pDestBufEnd
)
703 *pDestBufPtr
++ = 0x0E; /* SO */
709 if (pDestBufEnd
- pDestBufPtr
>= 4)
711 *pDestBufPtr
++ = (sal_Char
) (nBytes
>> 8);
712 *pDestBufPtr
++ = (sal_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
= sal_True
;
752 if (pDestBufEnd
- pDestBufPtr
>= 4)
754 *pDestBufPtr
++ = 0x1B; /* ESC */
755 *pDestBufPtr
++ = 0x4E; /* N */
757 = (sal_Char
) (0x20 + pCns116431992Data
[nOffset
++]);
759 = (sal_Char
) (0x20 + pCns116431992Data
[nOffset
]);
769 switch (ImplHandleBadInputUnicodeToTextConversion(bUndefined
,
779 case IMPL_BAD_INPUT_STOP
:
783 case IMPL_BAD_INPUT_CONTINUE
:
789 case IMPL_BAD_INPUT_NO_OUTPUT
:
796 nInfo
|= RTL_UNICODETOTEXT_INFO_DESTBUFFERTOSMALL
;
800 if ((nInfo
& (RTL_UNICODETOTEXT_INFO_ERROR
801 | RTL_UNICODETOTEXT_INFO_DESTBUFFERTOSMALL
))
804 sal_Bool bFlush
= sal_True
;
805 if (nHighSurrogate
!= 0)
807 if ((nFlags
& RTL_UNICODETOTEXT_FLAGS_FLUSH
) != 0)
808 nInfo
|= RTL_UNICODETOTEXT_INFO_SRCBUFFERTOSMALL
;
810 switch (ImplHandleBadInputUnicodeToTextConversion(
821 case IMPL_BAD_INPUT_STOP
:
826 case IMPL_BAD_INPUT_CONTINUE
:
832 case IMPL_BAD_INPUT_NO_OUTPUT
:
833 nInfo
|= RTL_UNICODETOTEXT_INFO_DESTBUFFERTOSMALL
;
837 if (bFlush
&& bSo
&& (nFlags
& RTL_UNICODETOTEXT_FLAGS_FLUSH
) != 0)
839 if (pDestBufPtr
!= pDestBufEnd
)
841 *pDestBufPtr
++ = 0x0F; /* SI */
845 nInfo
|= RTL_UNICODETOTEXT_INFO_DESTBUFFERTOSMALL
;
851 ((ImplUnicodeToIso2022CnContext
*) pContext
)->m_nHighSurrogate
853 ((ImplUnicodeToIso2022CnContext
*) pContext
)->m_eSoDesignator
855 ((ImplUnicodeToIso2022CnContext
*) pContext
)->m_b116432Designator
857 ((ImplUnicodeToIso2022CnContext
*) pContext
)->m_bSo
= bSo
;
862 *pSrcCvtChars
= nConverted
;
864 return pDestBufPtr
- pDestBuf
;