1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #include "sal/config.h"
31 #include "rtl/textcvt.h"
32 #include "sal/types.h"
34 #include "context.hxx"
35 #include "converter.hxx"
36 #include "convertiso2022cn.hxx"
37 #include "tenchelp.hxx"
38 #include "unichars.hxx"
42 enum ImplIso2022CnToUnicodeState
// order is important:
44 IMPL_ISO_2022_CN_TO_UNICODE_STATE_ASCII
,
45 IMPL_ISO_2022_CN_TO_UNICODE_STATE_SO
,
46 IMPL_ISO_2022_CN_TO_UNICODE_STATE_SO_2
,
47 IMPL_ISO_2022_CN_TO_UNICODE_STATE_116432
,
48 IMPL_ISO_2022_CN_TO_UNICODE_STATE_116432_2
,
49 IMPL_ISO_2022_CN_TO_UNICODE_STATE_ESC
,
50 IMPL_ISO_2022_CN_TO_UNICODE_STATE_ESC_DOLLAR
,
51 IMPL_ISO_2022_CN_TO_UNICODE_STATE_ESC_DOLLAR_RPAREN
,
52 IMPL_ISO_2022_CN_TO_UNICODE_STATE_ESC_DOLLAR_ASTERISK
55 struct ImplIso2022CnToUnicodeContext
57 ImplIso2022CnToUnicodeState m_eState
;
63 enum ImplUnicodeToIso2022CnDesignator
65 IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_NONE
,
66 IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_2312
,
67 IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_116431
70 struct ImplUnicodeToIso2022CnContext
72 sal_Unicode m_nHighSurrogate
;
73 ImplUnicodeToIso2022CnDesignator m_eSoDesignator
;
74 bool m_b116432Designator
;
80 void * ImplCreateIso2022CnToUnicodeContext()
82 ImplIso2022CnToUnicodeContext
* pContext
=
83 new ImplIso2022CnToUnicodeContext
;
84 pContext
->m_eState
= IMPL_ISO_2022_CN_TO_UNICODE_STATE_ASCII
;
85 pContext
->m_bSo
= false;
86 pContext
->m_b116431
= false;
90 void ImplResetIso2022CnToUnicodeContext(void * pContext
)
94 static_cast< ImplIso2022CnToUnicodeContext
* >(pContext
)->m_eState
95 = IMPL_ISO_2022_CN_TO_UNICODE_STATE_ASCII
;
96 static_cast< ImplIso2022CnToUnicodeContext
* >(pContext
)->m_bSo
= false;
97 static_cast< ImplIso2022CnToUnicodeContext
* >(pContext
)->m_b116431
= false;
101 void ImplDestroyIso2022CnToUnicodeContext(void * pContext
)
103 delete static_cast< ImplIso2022CnToUnicodeContext
* >(pContext
);
106 sal_Size
ImplConvertIso2022CnToUnicode(void const * pData
,
108 char const * pSrcBuf
,
110 sal_Unicode
* pDestBuf
,
114 sal_Size
* pSrcCvtBytes
)
116 ImplDBCSToUniLeadTab
const * pGb2312Data
117 = static_cast< ImplIso2022CnConverterData
const * >(pData
)->
118 m_pGb2312ToUnicodeData
;
119 sal_uInt16
const * pCns116431992Data
120 = static_cast< ImplIso2022CnConverterData
const * >(pData
)->
121 m_pCns116431992ToUnicodeData
;
122 sal_Int32
const * pCns116431992RowOffsets
123 = static_cast< ImplIso2022CnConverterData
const * >(pData
)->
124 m_pCns116431992ToUnicodeRowOffsets
;
125 sal_Int32
const * pCns116431992PlaneOffsets
126 = static_cast< ImplIso2022CnConverterData
const * >(pData
)->
127 m_pCns116431992ToUnicodePlaneOffsets
;
128 ImplIso2022CnToUnicodeState eState
129 = IMPL_ISO_2022_CN_TO_UNICODE_STATE_ASCII
;
132 bool b116431
= false;
133 sal_uInt32 nInfo
= 0;
134 sal_Size nConverted
= 0;
135 sal_Unicode
* pDestBufPtr
= pDestBuf
;
136 sal_Unicode
* pDestBufEnd
= pDestBuf
+ nDestChars
;
140 eState
= static_cast< ImplIso2022CnToUnicodeContext
* >(pContext
)->m_eState
;
141 nRow
= static_cast< ImplIso2022CnToUnicodeContext
* >(pContext
)->m_nRow
;
142 bSo
= static_cast< ImplIso2022CnToUnicodeContext
* >(pContext
)->m_bSo
;
143 b116431
= static_cast< ImplIso2022CnToUnicodeContext
* >(pContext
)->m_b116431
;
146 for (; nConverted
< nSrcBytes
; ++nConverted
)
148 bool bUndefined
= true;
149 sal_uInt32 nChar
= *(sal_uChar
const *) pSrcBuf
++;
153 case IMPL_ISO_2022_CN_TO_UNICODE_STATE_ASCII
:
154 if (nChar
== 0x0E) // SO
157 eState
= IMPL_ISO_2022_CN_TO_UNICODE_STATE_SO
;
159 else if (nChar
== 0x1B) // ESC
160 eState
= IMPL_ISO_2022_CN_TO_UNICODE_STATE_ESC
;
161 else if (nChar
< 0x80)
162 if (pDestBufPtr
!= pDestBufEnd
)
163 *pDestBufPtr
++ = (sal_Unicode
) nChar
;
173 case IMPL_ISO_2022_CN_TO_UNICODE_STATE_SO
:
174 if (nChar
== 0x0F) // SI
177 eState
= IMPL_ISO_2022_CN_TO_UNICODE_STATE_ASCII
;
179 else if (nChar
== 0x1B) // ESC
180 eState
= IMPL_ISO_2022_CN_TO_UNICODE_STATE_ESC
;
181 else if (nChar
>= 0x21 && nChar
<= 0x7E)
184 eState
= IMPL_ISO_2022_CN_TO_UNICODE_STATE_SO_2
;
193 case IMPL_ISO_2022_CN_TO_UNICODE_STATE_SO_2
:
194 if (nChar
>= 0x21 && nChar
<= 0x7E)
202 sal_uInt16 nUnicode
= 0;
206 nFirst
= pGb2312Data
[nRow
].mnTrailStart
;
208 && nChar
<= pGb2312Data
[nRow
].mnTrailEnd
)
209 nUnicode
= pGb2312Data
[nRow
].
210 mpToUniTrailTab
[nChar
- nFirst
];
212 if (pDestBufPtr
!= pDestBufEnd
)
214 *pDestBufPtr
++ = (sal_Unicode
) nUnicode
;
215 eState
= IMPL_ISO_2022_CN_TO_UNICODE_STATE_SO
;
229 case IMPL_ISO_2022_CN_TO_UNICODE_STATE_116432
:
230 if (nChar
>= 0x21 && nChar
<= 0x7E)
233 eState
= IMPL_ISO_2022_CN_TO_UNICODE_STATE_116432_2
;
242 case IMPL_ISO_2022_CN_TO_UNICODE_STATE_116432_2
:
243 if (nChar
>= 0x21 && nChar
<= 0x7E)
255 case IMPL_ISO_2022_CN_TO_UNICODE_STATE_ESC
:
256 if (nChar
== 0x24) // $
257 eState
= IMPL_ISO_2022_CN_TO_UNICODE_STATE_ESC_DOLLAR
;
258 else if (nChar
== 0x4E) // N
259 eState
= IMPL_ISO_2022_CN_TO_UNICODE_STATE_116432
;
267 case IMPL_ISO_2022_CN_TO_UNICODE_STATE_ESC_DOLLAR
:
268 if (nChar
== 0x29) // )
269 eState
= IMPL_ISO_2022_CN_TO_UNICODE_STATE_ESC_DOLLAR_RPAREN
;
270 else if (nChar
== 0x2A) // *
272 = IMPL_ISO_2022_CN_TO_UNICODE_STATE_ESC_DOLLAR_ASTERISK
;
280 case IMPL_ISO_2022_CN_TO_UNICODE_STATE_ESC_DOLLAR_RPAREN
:
281 if (nChar
== 0x41) // A
284 eState
= bSo
? IMPL_ISO_2022_CN_TO_UNICODE_STATE_SO
:
285 IMPL_ISO_2022_CN_TO_UNICODE_STATE_ASCII
;
287 else if (nChar
== 0x47) // G
290 eState
= bSo
? IMPL_ISO_2022_CN_TO_UNICODE_STATE_SO
:
291 IMPL_ISO_2022_CN_TO_UNICODE_STATE_ASCII
;
300 case IMPL_ISO_2022_CN_TO_UNICODE_STATE_ESC_DOLLAR_ASTERISK
:
301 if (nChar
== 0x48) // H
302 eState
= bSo
? IMPL_ISO_2022_CN_TO_UNICODE_STATE_SO
:
303 IMPL_ISO_2022_CN_TO_UNICODE_STATE_ASCII
;
315 sal_Int32 nPlaneOffset
= pCns116431992PlaneOffsets
[nPlane
];
316 if (nPlaneOffset
== -1)
321 = pCns116431992RowOffsets
[nPlaneOffset
+ (nRow
- 0x21)];
326 sal_uInt32 nFirstLast
= pCns116431992Data
[nOffset
++];
327 sal_uInt32 nFirst
= nFirstLast
& 0xFF;
328 sal_uInt32 nLast
= nFirstLast
>> 8;
330 if (nChar
>= nFirst
&& nChar
<= nLast
)
333 = pCns116431992Data
[nOffset
+ (nChar
- nFirst
)];
334 if (nUnicode
== 0xFFFF)
336 else if (ImplIsHighSurrogate(nUnicode
))
337 if (pDestBufEnd
- pDestBufPtr
>= 2)
339 nOffset
+= nLast
- nFirst
+ 1;
340 nFirst
= pCns116431992Data
[nOffset
++];
341 *pDestBufPtr
++ = (sal_Unicode
) nUnicode
;
345 nOffset
+ (nChar
- nFirst
)];
350 if (pDestBufPtr
!= pDestBufEnd
)
351 *pDestBufPtr
++ = (sal_Unicode
) nUnicode
;
357 eState
= bSo
? IMPL_ISO_2022_CN_TO_UNICODE_STATE_SO
:
358 IMPL_ISO_2022_CN_TO_UNICODE_STATE_ASCII
;
365 switch (sal::detail::textenc::handleBadInputTextToUnicodeConversion(
366 bUndefined
, true, 0, nFlags
, &pDestBufPtr
, pDestBufEnd
,
369 case sal::detail::textenc::BAD_INPUT_STOP
:
370 eState
= IMPL_ISO_2022_CN_TO_UNICODE_STATE_ASCII
;
374 case sal::detail::textenc::BAD_INPUT_CONTINUE
:
375 eState
= IMPL_ISO_2022_CN_TO_UNICODE_STATE_ASCII
;
379 case sal::detail::textenc::BAD_INPUT_NO_OUTPUT
:
386 nInfo
|= RTL_TEXTTOUNICODE_INFO_DESTBUFFERTOSMALL
;
390 if (eState
> IMPL_ISO_2022_CN_TO_UNICODE_STATE_SO
391 && (nInfo
& (RTL_TEXTTOUNICODE_INFO_ERROR
392 | RTL_TEXTTOUNICODE_INFO_DESTBUFFERTOSMALL
))
395 if ((nFlags
& RTL_TEXTTOUNICODE_FLAGS_FLUSH
) == 0)
396 nInfo
|= RTL_TEXTTOUNICODE_INFO_SRCBUFFERTOSMALL
;
398 switch (sal::detail::textenc::handleBadInputTextToUnicodeConversion(
399 false, true, 0, nFlags
, &pDestBufPtr
, pDestBufEnd
,
402 case sal::detail::textenc::BAD_INPUT_STOP
:
403 case sal::detail::textenc::BAD_INPUT_CONTINUE
:
404 eState
= IMPL_ISO_2022_CN_TO_UNICODE_STATE_ASCII
;
408 case sal::detail::textenc::BAD_INPUT_NO_OUTPUT
:
409 nInfo
|= RTL_TEXTTOUNICODE_INFO_DESTBUFFERTOSMALL
;
416 static_cast< ImplIso2022CnToUnicodeContext
* >(pContext
)->m_eState
= eState
;
417 static_cast< ImplIso2022CnToUnicodeContext
* >(pContext
)->m_nRow
= nRow
;
418 static_cast< ImplIso2022CnToUnicodeContext
* >(pContext
)->m_bSo
= bSo
;
419 static_cast< ImplIso2022CnToUnicodeContext
* >(pContext
)->m_b116431
= b116431
;
424 *pSrcCvtBytes
= nConverted
;
426 return pDestBufPtr
- pDestBuf
;
429 void * ImplCreateUnicodeToIso2022CnContext(void)
431 ImplUnicodeToIso2022CnContext
* pContext
=
432 new ImplUnicodeToIso2022CnContext
;
433 pContext
->m_nHighSurrogate
= 0;
434 pContext
->m_eSoDesignator
= IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_NONE
;
435 pContext
->m_b116432Designator
= false;
436 pContext
->m_bSo
= false;
440 void ImplResetUnicodeToIso2022CnContext(void * pContext
)
444 static_cast< ImplUnicodeToIso2022CnContext
* >(pContext
)->m_nHighSurrogate
= 0;
445 static_cast< ImplUnicodeToIso2022CnContext
* >(pContext
)->m_eSoDesignator
446 = IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_NONE
;
447 static_cast< ImplUnicodeToIso2022CnContext
* >(pContext
)->m_b116432Designator
449 static_cast< ImplUnicodeToIso2022CnContext
* >(pContext
)->m_bSo
= false;
453 void ImplDestroyUnicodeToIso2022CnContext(void * pContext
)
455 delete static_cast< ImplUnicodeToIso2022CnContext
* >(pContext
);
458 static sal_uInt32
ImplIso2022CnTranslateTo2312(ImplUniToDBCSHighTab
const *
462 sal_uInt32 nIndex1
= nChar
>> 8;
465 sal_uInt32 nIndex2
= nChar
& 0xFF;
466 sal_uInt32 nFirst
= pGb2312Data
[nIndex1
].mnLowStart
;
467 if (nIndex2
>= nFirst
&& nIndex2
<= pGb2312Data
[nIndex1
].mnLowEnd
)
468 return pGb2312Data
[nIndex1
].mpToUniTrailTab
[nIndex2
- nFirst
]
475 ImplIso2022CnTranslateTo116431(sal_uInt8
const * pCns116431992Data
,
476 sal_Int32
const * pCns116431992PageOffsets
,
477 sal_Int32
const * pCns116431992PlaneOffsets
,
480 sal_Int32 nOffset
= pCns116431992PlaneOffsets
[nChar
>> 16];
486 nOffset
= pCns116431992PageOffsets
[nOffset
+ ((nChar
& 0xFF00) >> 8)];
489 nFirst
= pCns116431992Data
[nOffset
++];
490 nLast
= pCns116431992Data
[nOffset
++];
492 if (nChar
< nFirst
|| nChar
> nLast
)
494 nOffset
+= 3 * (nChar
- nFirst
);
495 nPlane
= pCns116431992Data
[nOffset
++];
498 return (0x20 + pCns116431992Data
[nOffset
]) << 8
499 | (0x20 + pCns116431992Data
[nOffset
+ 1]);
502 sal_Size
ImplConvertUnicodeToIso2022Cn(void const * pData
,
504 sal_Unicode
const * pSrcBuf
,
510 sal_Size
* pSrcCvtChars
)
512 ImplUniToDBCSHighTab
const * pGb2312Data
513 = static_cast< ImplIso2022CnConverterData
const * >(pData
)->
514 m_pUnicodeToGb2312Data
;
515 sal_uInt8
const * pCns116431992Data
516 = static_cast< ImplIso2022CnConverterData
const * >(pData
)->
517 m_pUnicodeToCns116431992Data
;
518 sal_Int32
const * pCns116431992PageOffsets
519 = static_cast< ImplIso2022CnConverterData
const * >(pData
)->
520 m_pUnicodeToCns116431992PageOffsets
;
521 sal_Int32
const * pCns116431992PlaneOffsets
522 = static_cast< ImplIso2022CnConverterData
const * >(pData
)->
523 m_pUnicodeToCns116431992PlaneOffsets
;
524 sal_Unicode nHighSurrogate
= 0;
525 ImplUnicodeToIso2022CnDesignator eSoDesignator
526 = IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_NONE
;
527 bool b116432Designator
= false;
529 sal_uInt32 nInfo
= 0;
530 sal_Size nConverted
= 0;
531 char * pDestBufPtr
= pDestBuf
;
532 char * pDestBufEnd
= pDestBuf
+ nDestBytes
;
538 = static_cast< ImplUnicodeToIso2022CnContext
* >(pContext
)->m_nHighSurrogate
;
540 = static_cast< ImplUnicodeToIso2022CnContext
* >(pContext
)->m_eSoDesignator
;
541 b116432Designator
= static_cast< ImplUnicodeToIso2022CnContext
* >(pContext
)->
543 bSo
= static_cast< ImplUnicodeToIso2022CnContext
* >(pContext
)->m_bSo
;
546 for (; nConverted
< nSrcChars
; ++nConverted
)
548 bool bUndefined
= true;
549 sal_uInt32 nChar
= *pSrcBuf
++;
550 if (nHighSurrogate
== 0)
552 if (ImplIsHighSurrogate(nChar
))
554 nHighSurrogate
= (sal_Unicode
) nChar
;
558 else if (ImplIsLowSurrogate(nChar
))
559 nChar
= ImplCombineSurrogates(nHighSurrogate
, nChar
);
566 if (ImplIsLowSurrogate(nChar
) || ImplIsNoncharacter(nChar
))
572 if (nChar
== 0x0A || nChar
== 0x0D) // LF, CR
576 if (pDestBufPtr
!= pDestBufEnd
)
578 *pDestBufPtr
++ = 0x0F; // SI
581 = IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_NONE
;
582 b116432Designator
= false;
587 if (pDestBufPtr
!= pDestBufEnd
)
588 *pDestBufPtr
++ = static_cast< char >(nChar
);
592 else if (nChar
== 0x0E || nChar
== 0x0F || nChar
== 0x1B)
594 else if (nChar
< 0x80)
598 if (pDestBufPtr
!= pDestBufEnd
)
600 *pDestBufPtr
++ = 0x0F; // SI
606 if (pDestBufPtr
!= pDestBufEnd
)
607 *pDestBufPtr
++ = static_cast< char >(nChar
);
613 sal_uInt32 nBytes
= 0;
614 ImplUnicodeToIso2022CnDesignator eNewDesignator
=
615 IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_NONE
;
616 switch (eSoDesignator
)
618 case IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_NONE
:
619 nBytes
= ImplIso2022CnTranslateTo2312(pGb2312Data
, nChar
);
623 = IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_2312
;
626 nBytes
= ImplIso2022CnTranslateTo116431(
628 pCns116431992PageOffsets
,
629 pCns116431992PlaneOffsets
,
634 = IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_116431
;
639 case IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_2312
:
640 nBytes
= ImplIso2022CnTranslateTo2312(pGb2312Data
, nChar
);
644 = IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_NONE
;
647 nBytes
= ImplIso2022CnTranslateTo116431(
649 pCns116431992PageOffsets
,
650 pCns116431992PlaneOffsets
,
655 = IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_116431
;
660 case IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_116431
:
661 nBytes
= ImplIso2022CnTranslateTo116431(
663 pCns116431992PageOffsets
,
664 pCns116431992PlaneOffsets
,
669 = IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_NONE
;
672 nBytes
= ImplIso2022CnTranslateTo2312(pGb2312Data
, nChar
);
676 = IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_2312
;
684 != IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_NONE
)
688 if (pDestBufPtr
!= pDestBufEnd
)
690 *pDestBufPtr
++ = 0x0F; // SI
696 if (pDestBufEnd
- pDestBufPtr
>= 4)
698 *pDestBufPtr
++ = 0x1B; // ESC
699 *pDestBufPtr
++ = 0x24; // $
700 *pDestBufPtr
++ = 0x29; // )
703 == IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_2312
?
705 eSoDesignator
= eNewDesignator
;
712 if (pDestBufPtr
!= pDestBufEnd
)
714 *pDestBufPtr
++ = 0x0E; // SO
720 if (pDestBufEnd
- pDestBufPtr
>= 4)
722 *pDestBufPtr
++ = static_cast< char >(nBytes
>> 8);
723 *pDestBufPtr
++ = static_cast< char >(nBytes
& 0xFF);
730 sal_Int32 nOffset
= pCns116431992PlaneOffsets
[nChar
>> 16];
737 = pCns116431992PageOffsets
[nOffset
738 + ((nChar
& 0xFF00) >> 8)];
741 nFirst
= pCns116431992Data
[nOffset
++];
742 nLast
= pCns116431992Data
[nOffset
++];
744 if (nChar
< nFirst
|| nChar
> nLast
)
746 nOffset
+= 3 * (nChar
- nFirst
);
747 nPlane
= pCns116431992Data
[nOffset
++];
750 if (!b116432Designator
)
752 if (pDestBufEnd
- pDestBufPtr
>= 4)
754 *pDestBufPtr
++ = 0x1B; // ESC
755 *pDestBufPtr
++ = 0x24; // $
756 *pDestBufPtr
++ = 0x2A; // *
757 *pDestBufPtr
++ = 0x48; // H
758 b116432Designator
= true;
763 if (pDestBufEnd
- pDestBufPtr
>= 4)
765 *pDestBufPtr
++ = 0x1B; // ESC
766 *pDestBufPtr
++ = 0x4E; // N
768 = static_cast< char >(0x20 + pCns116431992Data
[nOffset
++]);
770 = static_cast< char >(0x20 + pCns116431992Data
[nOffset
]);
780 switch (sal::detail::textenc::handleBadInputUnicodeToTextConversion(
781 bUndefined
, nChar
, nFlags
, &pDestBufPtr
, pDestBufEnd
,
782 &nInfo
, "\x0F" /* SI */, bSo
? 1 : 0, &bWritten
))
784 case sal::detail::textenc::BAD_INPUT_STOP
:
788 case sal::detail::textenc::BAD_INPUT_CONTINUE
:
794 case sal::detail::textenc::BAD_INPUT_NO_OUTPUT
:
801 nInfo
|= RTL_UNICODETOTEXT_INFO_DESTBUFFERTOSMALL
;
805 if ((nInfo
& (RTL_UNICODETOTEXT_INFO_ERROR
806 | RTL_UNICODETOTEXT_INFO_DESTBUFFERTOSMALL
))
810 if (nHighSurrogate
!= 0)
812 if ((nFlags
& RTL_UNICODETOTEXT_FLAGS_FLUSH
) != 0)
813 nInfo
|= RTL_UNICODETOTEXT_INFO_SRCBUFFERTOSMALL
;
815 switch (sal::detail::textenc::handleBadInputUnicodeToTextConversion(
816 false, 0, nFlags
, &pDestBufPtr
, pDestBufEnd
, &nInfo
,
817 "\x0F" /* SI */, bSo
? 1 : 0, &bWritten
))
819 case sal::detail::textenc::BAD_INPUT_STOP
:
824 case sal::detail::textenc::BAD_INPUT_CONTINUE
:
830 case sal::detail::textenc::BAD_INPUT_NO_OUTPUT
:
831 nInfo
|= RTL_UNICODETOTEXT_INFO_DESTBUFFERTOSMALL
;
835 if (bFlush
&& bSo
&& (nFlags
& RTL_UNICODETOTEXT_FLAGS_FLUSH
) != 0)
837 if (pDestBufPtr
!= pDestBufEnd
)
839 *pDestBufPtr
++ = 0x0F; // SI
843 nInfo
|= RTL_UNICODETOTEXT_INFO_DESTBUFFERTOSMALL
;
849 static_cast< ImplUnicodeToIso2022CnContext
* >(pContext
)->m_nHighSurrogate
851 static_cast< ImplUnicodeToIso2022CnContext
* >(pContext
)->m_eSoDesignator
853 static_cast< ImplUnicodeToIso2022CnContext
* >(pContext
)->m_b116432Designator
855 static_cast< ImplUnicodeToIso2022CnContext
* >(pContext
)->m_bSo
= bSo
;
860 *pSrcCvtChars
= nConverted
;
862 return pDestBufPtr
- pDestBuf
;
865 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */