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>
24 #include <rtl/character.hxx>
25 #include <rtl/textcvt.h>
26 #include <sal/types.h>
28 #include "converter.hxx"
29 #include "convertiso2022cn.hxx"
30 #include "tenchelp.hxx"
34 enum ImplIso2022CnToUnicodeState
// order is important:
36 IMPL_ISO_2022_CN_TO_UNICODE_STATE_ASCII
,
37 IMPL_ISO_2022_CN_TO_UNICODE_STATE_SO
,
38 IMPL_ISO_2022_CN_TO_UNICODE_STATE_SO_2
,
39 IMPL_ISO_2022_CN_TO_UNICODE_STATE_116432
,
40 IMPL_ISO_2022_CN_TO_UNICODE_STATE_116432_2
,
41 IMPL_ISO_2022_CN_TO_UNICODE_STATE_ESC
,
42 IMPL_ISO_2022_CN_TO_UNICODE_STATE_ESC_DOLLAR
,
43 IMPL_ISO_2022_CN_TO_UNICODE_STATE_ESC_DOLLAR_RPAREN
,
44 IMPL_ISO_2022_CN_TO_UNICODE_STATE_ESC_DOLLAR_ASTERISK
47 struct ImplIso2022CnToUnicodeContext
49 ImplIso2022CnToUnicodeState m_eState
;
55 enum ImplUnicodeToIso2022CnDesignator
57 IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_NONE
,
58 IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_2312
,
59 IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_116431
62 struct ImplUnicodeToIso2022CnContext
64 sal_Unicode m_nHighSurrogate
;
65 ImplUnicodeToIso2022CnDesignator m_eSoDesignator
;
66 bool m_b116432Designator
;
72 void * ImplCreateIso2022CnToUnicodeContext()
74 ImplIso2022CnToUnicodeContext
* pContext
=
75 new ImplIso2022CnToUnicodeContext
;
76 pContext
->m_eState
= IMPL_ISO_2022_CN_TO_UNICODE_STATE_ASCII
;
77 pContext
->m_bSo
= false;
78 pContext
->m_b116431
= false;
82 void ImplResetIso2022CnToUnicodeContext(void * pContext
)
86 static_cast< ImplIso2022CnToUnicodeContext
* >(pContext
)->m_eState
87 = IMPL_ISO_2022_CN_TO_UNICODE_STATE_ASCII
;
88 static_cast< ImplIso2022CnToUnicodeContext
* >(pContext
)->m_bSo
= false;
89 static_cast< ImplIso2022CnToUnicodeContext
* >(pContext
)->m_b116431
= false;
93 void ImplDestroyIso2022CnToUnicodeContext(void * pContext
)
95 delete static_cast< ImplIso2022CnToUnicodeContext
* >(pContext
);
98 sal_Size
ImplConvertIso2022CnToUnicode(void const * pData
,
100 char const * pSrcBuf
,
102 sal_Unicode
* pDestBuf
,
106 sal_Size
* pSrcCvtBytes
)
108 ImplDBCSToUniLeadTab
const * pGb2312Data
109 = static_cast< ImplIso2022CnConverterData
const * >(pData
)->
110 m_pGb2312ToUnicodeData
;
111 sal_uInt16
const * pCns116431992Data
112 = static_cast< ImplIso2022CnConverterData
const * >(pData
)->
113 m_pCns116431992ToUnicodeData
;
114 sal_Int32
const * pCns116431992RowOffsets
115 = static_cast< ImplIso2022CnConverterData
const * >(pData
)->
116 m_pCns116431992ToUnicodeRowOffsets
;
117 sal_Int32
const * pCns116431992PlaneOffsets
118 = static_cast< ImplIso2022CnConverterData
const * >(pData
)->
119 m_pCns116431992ToUnicodePlaneOffsets
;
120 ImplIso2022CnToUnicodeState eState
121 = IMPL_ISO_2022_CN_TO_UNICODE_STATE_ASCII
;
124 bool b116431
= false;
125 sal_uInt32 nInfo
= 0;
126 sal_Size nConverted
= 0;
127 sal_Unicode
* pDestBufPtr
= pDestBuf
;
128 sal_Unicode
* pDestBufEnd
= pDestBuf
+ nDestChars
;
129 sal_Size startOfCurrentChar
= 0;
133 eState
= static_cast< ImplIso2022CnToUnicodeContext
* >(pContext
)->m_eState
;
134 nRow
= static_cast< ImplIso2022CnToUnicodeContext
* >(pContext
)->m_nRow
;
135 bSo
= static_cast< ImplIso2022CnToUnicodeContext
* >(pContext
)->m_bSo
;
136 b116431
= static_cast< ImplIso2022CnToUnicodeContext
* >(pContext
)->m_b116431
;
139 for (; nConverted
< nSrcBytes
; ++nConverted
)
141 bool bUndefined
= true;
142 sal_uInt32 nChar
= *reinterpret_cast<unsigned char const *>(pSrcBuf
++);
146 case IMPL_ISO_2022_CN_TO_UNICODE_STATE_ASCII
:
147 if (nChar
== 0x0E) // SO
150 eState
= IMPL_ISO_2022_CN_TO_UNICODE_STATE_SO
;
152 else if (nChar
== 0x1B) // ESC
153 eState
= IMPL_ISO_2022_CN_TO_UNICODE_STATE_ESC
;
154 else if (nChar
< 0x80)
155 if (pDestBufPtr
!= pDestBufEnd
) {
156 *pDestBufPtr
++ = static_cast<sal_Unicode
>(nChar
);
157 startOfCurrentChar
= nConverted
+ 1;
167 case IMPL_ISO_2022_CN_TO_UNICODE_STATE_SO
:
168 if (nChar
== 0x0F) // SI
171 eState
= IMPL_ISO_2022_CN_TO_UNICODE_STATE_ASCII
;
173 else if (nChar
== 0x1B) // ESC
174 eState
= IMPL_ISO_2022_CN_TO_UNICODE_STATE_ESC
;
175 else if (nChar
>= 0x21 && nChar
<= 0x7E)
178 eState
= IMPL_ISO_2022_CN_TO_UNICODE_STATE_SO_2
;
187 case IMPL_ISO_2022_CN_TO_UNICODE_STATE_SO_2
:
188 if (nChar
>= 0x21 && nChar
<= 0x7E)
196 sal_uInt16 nUnicode
= 0;
200 nFirst
= pGb2312Data
[nRow
].mnTrailStart
;
202 && nChar
<= pGb2312Data
[nRow
].mnTrailEnd
)
203 nUnicode
= pGb2312Data
[nRow
].
204 mpToUniTrailTab
[nChar
- nFirst
];
206 if (pDestBufPtr
!= pDestBufEnd
)
208 *pDestBufPtr
++ = static_cast<sal_Unicode
>(nUnicode
);
209 eState
= IMPL_ISO_2022_CN_TO_UNICODE_STATE_SO
;
210 startOfCurrentChar
= nConverted
+ 1;
224 case IMPL_ISO_2022_CN_TO_UNICODE_STATE_116432
:
225 if (nChar
>= 0x21 && nChar
<= 0x7E)
228 eState
= IMPL_ISO_2022_CN_TO_UNICODE_STATE_116432_2
;
237 case IMPL_ISO_2022_CN_TO_UNICODE_STATE_116432_2
:
238 if (nChar
>= 0x21 && nChar
<= 0x7E)
250 case IMPL_ISO_2022_CN_TO_UNICODE_STATE_ESC
:
251 if (nChar
== 0x24) // $
252 eState
= IMPL_ISO_2022_CN_TO_UNICODE_STATE_ESC_DOLLAR
;
253 else if (nChar
== 0x4E) // N
254 eState
= IMPL_ISO_2022_CN_TO_UNICODE_STATE_116432
;
262 case IMPL_ISO_2022_CN_TO_UNICODE_STATE_ESC_DOLLAR
:
263 if (nChar
== 0x29) // )
264 eState
= IMPL_ISO_2022_CN_TO_UNICODE_STATE_ESC_DOLLAR_RPAREN
;
265 else if (nChar
== 0x2A) // *
267 = IMPL_ISO_2022_CN_TO_UNICODE_STATE_ESC_DOLLAR_ASTERISK
;
275 case IMPL_ISO_2022_CN_TO_UNICODE_STATE_ESC_DOLLAR_RPAREN
:
276 if (nChar
== 0x41) // A
279 eState
= bSo
? IMPL_ISO_2022_CN_TO_UNICODE_STATE_SO
:
280 IMPL_ISO_2022_CN_TO_UNICODE_STATE_ASCII
;
282 else if (nChar
== 0x47) // G
285 eState
= bSo
? IMPL_ISO_2022_CN_TO_UNICODE_STATE_SO
:
286 IMPL_ISO_2022_CN_TO_UNICODE_STATE_ASCII
;
295 case IMPL_ISO_2022_CN_TO_UNICODE_STATE_ESC_DOLLAR_ASTERISK
:
296 if (nChar
== 0x48) // H
297 eState
= bSo
? IMPL_ISO_2022_CN_TO_UNICODE_STATE_SO
:
298 IMPL_ISO_2022_CN_TO_UNICODE_STATE_ASCII
;
310 sal_Int32 nPlaneOffset
= pCns116431992PlaneOffsets
[nPlane
];
311 if (nPlaneOffset
== -1)
316 = pCns116431992RowOffsets
[nPlaneOffset
+ (nRow
- 0x21)];
321 sal_uInt32 nFirstLast
= pCns116431992Data
[nOffset
++];
322 sal_uInt32 nFirst
= nFirstLast
& 0xFF;
323 sal_uInt32 nLast
= nFirstLast
>> 8;
325 if (nChar
>= nFirst
&& nChar
<= nLast
)
328 = pCns116431992Data
[nOffset
+ (nChar
- nFirst
)];
329 if (nUnicode
== 0xFFFF)
331 else if (rtl::isHighSurrogate(nUnicode
))
332 if (pDestBufEnd
- pDestBufPtr
>= 2)
334 nOffset
+= nLast
- nFirst
+ 1;
335 nFirst
= pCns116431992Data
[nOffset
++];
336 *pDestBufPtr
++ = static_cast<sal_Unicode
>(nUnicode
);
338 = static_cast<sal_Unicode
>(pCns116431992Data
[
339 nOffset
+ (nChar
- nFirst
)]);
340 startOfCurrentChar
= nConverted
+ 1;
345 if (pDestBufPtr
!= pDestBufEnd
) {
346 *pDestBufPtr
++ = static_cast<sal_Unicode
>(nUnicode
);
347 startOfCurrentChar
= nConverted
+ 1;
353 eState
= bSo
? IMPL_ISO_2022_CN_TO_UNICODE_STATE_SO
:
354 IMPL_ISO_2022_CN_TO_UNICODE_STATE_ASCII
;
361 switch (sal::detail::textenc::handleBadInputTextToUnicodeConversion(
362 bUndefined
, true, 0, nFlags
, &pDestBufPtr
, pDestBufEnd
,
365 case sal::detail::textenc::BAD_INPUT_STOP
:
366 eState
= IMPL_ISO_2022_CN_TO_UNICODE_STATE_ASCII
;
368 if ((nFlags
& RTL_TEXTTOUNICODE_FLAGS_FLUSH
) == 0) {
371 nConverted
= startOfCurrentChar
;
375 case sal::detail::textenc::BAD_INPUT_CONTINUE
:
376 eState
= IMPL_ISO_2022_CN_TO_UNICODE_STATE_ASCII
;
378 startOfCurrentChar
= nConverted
+ 1;
381 case sal::detail::textenc::BAD_INPUT_NO_OUTPUT
:
388 nInfo
|= RTL_TEXTTOUNICODE_INFO_DESTBUFFERTOOSMALL
;
392 if (eState
> IMPL_ISO_2022_CN_TO_UNICODE_STATE_SO
393 && (nInfo
& (RTL_TEXTTOUNICODE_INFO_ERROR
394 | RTL_TEXTTOUNICODE_INFO_DESTBUFFERTOOSMALL
))
397 if ((nFlags
& RTL_TEXTTOUNICODE_FLAGS_FLUSH
) == 0)
398 nInfo
|= RTL_TEXTTOUNICODE_INFO_SRCBUFFERTOOSMALL
;
400 switch (sal::detail::textenc::handleBadInputTextToUnicodeConversion(
401 false, true, 0, nFlags
, &pDestBufPtr
, pDestBufEnd
,
404 case sal::detail::textenc::BAD_INPUT_STOP
:
405 if ((nFlags
& RTL_TEXTTOUNICODE_FLAGS_FLUSH
) != 0) {
406 nConverted
= startOfCurrentChar
;
409 case sal::detail::textenc::BAD_INPUT_CONTINUE
:
410 eState
= IMPL_ISO_2022_CN_TO_UNICODE_STATE_ASCII
;
414 case sal::detail::textenc::BAD_INPUT_NO_OUTPUT
:
415 nInfo
|= RTL_TEXTTOUNICODE_INFO_DESTBUFFERTOOSMALL
;
422 static_cast< ImplIso2022CnToUnicodeContext
* >(pContext
)->m_eState
= eState
;
423 static_cast< ImplIso2022CnToUnicodeContext
* >(pContext
)->m_nRow
= nRow
;
424 static_cast< ImplIso2022CnToUnicodeContext
* >(pContext
)->m_bSo
= bSo
;
425 static_cast< ImplIso2022CnToUnicodeContext
* >(pContext
)->m_b116431
= b116431
;
430 *pSrcCvtBytes
= nConverted
;
432 return pDestBufPtr
- pDestBuf
;
435 void * ImplCreateUnicodeToIso2022CnContext()
437 ImplUnicodeToIso2022CnContext
* pContext
=
438 new ImplUnicodeToIso2022CnContext
;
439 pContext
->m_nHighSurrogate
= 0;
440 pContext
->m_eSoDesignator
= IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_NONE
;
441 pContext
->m_b116432Designator
= false;
442 pContext
->m_bSo
= false;
446 void ImplResetUnicodeToIso2022CnContext(void * pContext
)
450 static_cast< ImplUnicodeToIso2022CnContext
* >(pContext
)->m_nHighSurrogate
= 0;
451 static_cast< ImplUnicodeToIso2022CnContext
* >(pContext
)->m_eSoDesignator
452 = IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_NONE
;
453 static_cast< ImplUnicodeToIso2022CnContext
* >(pContext
)->m_b116432Designator
455 static_cast< ImplUnicodeToIso2022CnContext
* >(pContext
)->m_bSo
= false;
459 void ImplDestroyUnicodeToIso2022CnContext(void * pContext
)
461 delete static_cast< ImplUnicodeToIso2022CnContext
* >(pContext
);
464 static sal_uInt32
ImplIso2022CnTranslateTo2312(ImplUniToDBCSHighTab
const *
468 sal_uInt32 nIndex1
= nChar
>> 8;
471 sal_uInt32 nIndex2
= nChar
& 0xFF;
472 sal_uInt32 nFirst
= pGb2312Data
[nIndex1
].mnLowStart
;
473 if (nIndex2
>= nFirst
&& nIndex2
<= pGb2312Data
[nIndex1
].mnLowEnd
)
474 return pGb2312Data
[nIndex1
].mpToUniTrailTab
[nIndex2
- nFirst
]
481 ImplIso2022CnTranslateTo116431(sal_uInt8
const * pCns116431992Data
,
482 sal_Int32
const * pCns116431992PageOffsets
,
483 sal_Int32
const * pCns116431992PlaneOffsets
,
486 sal_Int32 nOffset
= pCns116431992PlaneOffsets
[nChar
>> 16];
492 nOffset
= pCns116431992PageOffsets
[nOffset
+ ((nChar
& 0xFF00) >> 8)];
495 nFirst
= pCns116431992Data
[nOffset
++];
496 nLast
= pCns116431992Data
[nOffset
++];
498 if (nChar
< nFirst
|| nChar
> nLast
)
500 nOffset
+= 3 * (nChar
- nFirst
);
501 nPlane
= pCns116431992Data
[nOffset
++];
504 return (0x20 + pCns116431992Data
[nOffset
]) << 8
505 | (0x20 + pCns116431992Data
[nOffset
+ 1]);
508 sal_Size
ImplConvertUnicodeToIso2022Cn(void const * pData
,
510 sal_Unicode
const * pSrcBuf
,
516 sal_Size
* pSrcCvtChars
)
518 ImplUniToDBCSHighTab
const * pGb2312Data
519 = static_cast< ImplIso2022CnConverterData
const * >(pData
)->
520 m_pUnicodeToGb2312Data
;
521 sal_uInt8
const * pCns116431992Data
522 = static_cast< ImplIso2022CnConverterData
const * >(pData
)->
523 m_pUnicodeToCns116431992Data
;
524 sal_Int32
const * pCns116431992PageOffsets
525 = static_cast< ImplIso2022CnConverterData
const * >(pData
)->
526 m_pUnicodeToCns116431992PageOffsets
;
527 sal_Int32
const * pCns116431992PlaneOffsets
528 = static_cast< ImplIso2022CnConverterData
const * >(pData
)->
529 m_pUnicodeToCns116431992PlaneOffsets
;
530 sal_Unicode nHighSurrogate
= 0;
531 ImplUnicodeToIso2022CnDesignator eSoDesignator
532 = IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_NONE
;
533 bool b116432Designator
= false;
535 sal_uInt32 nInfo
= 0;
536 sal_Size nConverted
= 0;
537 char * pDestBufPtr
= pDestBuf
;
538 char * pDestBufEnd
= pDestBuf
+ nDestBytes
;
544 = static_cast< ImplUnicodeToIso2022CnContext
* >(pContext
)->m_nHighSurrogate
;
546 = static_cast< ImplUnicodeToIso2022CnContext
* >(pContext
)->m_eSoDesignator
;
547 b116432Designator
= static_cast< ImplUnicodeToIso2022CnContext
* >(pContext
)->
549 bSo
= static_cast< ImplUnicodeToIso2022CnContext
* >(pContext
)->m_bSo
;
552 for (; nConverted
< nSrcChars
; ++nConverted
)
554 bool bUndefined
= true;
555 sal_uInt32 nChar
= *pSrcBuf
++;
556 if (nHighSurrogate
== 0)
558 if (rtl::isHighSurrogate(nChar
))
560 nHighSurrogate
= static_cast<sal_Unicode
>(nChar
);
563 else if (rtl::isLowSurrogate(nChar
))
569 else if (rtl::isLowSurrogate(nChar
))
570 nChar
= rtl::combineSurrogates(nHighSurrogate
, nChar
);
577 assert(rtl::isUnicodeScalarValue(nChar
));
579 if (nChar
== 0x0A || nChar
== 0x0D) // LF, CR
583 if (pDestBufPtr
!= pDestBufEnd
)
585 *pDestBufPtr
++ = 0x0F; // SI
588 = IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_NONE
;
589 b116432Designator
= false;
594 if (pDestBufPtr
!= pDestBufEnd
)
595 *pDestBufPtr
++ = static_cast< char >(nChar
);
599 else if (nChar
== 0x0E || nChar
== 0x0F || nChar
== 0x1B)
601 else if (nChar
< 0x80)
605 if (pDestBufPtr
!= pDestBufEnd
)
607 *pDestBufPtr
++ = 0x0F; // SI
613 if (pDestBufPtr
!= pDestBufEnd
)
614 *pDestBufPtr
++ = static_cast< char >(nChar
);
620 sal_uInt32 nBytes
= 0;
621 ImplUnicodeToIso2022CnDesignator eNewDesignator
=
622 IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_NONE
;
623 switch (eSoDesignator
)
625 case IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_NONE
:
626 nBytes
= ImplIso2022CnTranslateTo2312(pGb2312Data
, nChar
);
630 = IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_2312
;
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_2312
:
647 nBytes
= ImplIso2022CnTranslateTo2312(pGb2312Data
, nChar
);
651 = IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_NONE
;
654 nBytes
= ImplIso2022CnTranslateTo116431(
656 pCns116431992PageOffsets
,
657 pCns116431992PlaneOffsets
,
662 = IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_116431
;
667 case IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_116431
:
668 nBytes
= ImplIso2022CnTranslateTo116431(
670 pCns116431992PageOffsets
,
671 pCns116431992PlaneOffsets
,
676 = IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_NONE
;
679 nBytes
= ImplIso2022CnTranslateTo2312(pGb2312Data
, nChar
);
683 = IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_2312
;
691 != IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_NONE
)
695 if (pDestBufPtr
!= pDestBufEnd
)
697 *pDestBufPtr
++ = 0x0F; // SI
703 if (pDestBufEnd
- pDestBufPtr
>= 4)
705 *pDestBufPtr
++ = 0x1B; // ESC
706 *pDestBufPtr
++ = 0x24; // $
707 *pDestBufPtr
++ = 0x29; // )
710 == IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_2312
?
712 eSoDesignator
= eNewDesignator
;
719 if (pDestBufPtr
!= pDestBufEnd
)
721 *pDestBufPtr
++ = 0x0E; // SO
727 if (pDestBufEnd
- pDestBufPtr
>= 4)
729 *pDestBufPtr
++ = static_cast< char >(nBytes
>> 8);
730 *pDestBufPtr
++ = static_cast< char >(nBytes
& 0xFF);
737 sal_Int32 nOffset
= pCns116431992PlaneOffsets
[nChar
>> 16];
744 = pCns116431992PageOffsets
[nOffset
745 + ((nChar
& 0xFF00) >> 8)];
748 nFirst
= pCns116431992Data
[nOffset
++];
749 nLast
= pCns116431992Data
[nOffset
++];
751 if (nChar
< nFirst
|| nChar
> nLast
)
753 nOffset
+= 3 * (nChar
- nFirst
);
754 nPlane
= pCns116431992Data
[nOffset
++];
757 if (!b116432Designator
)
759 if (pDestBufEnd
- pDestBufPtr
>= 4)
761 *pDestBufPtr
++ = 0x1B; // ESC
762 *pDestBufPtr
++ = 0x24; // $
763 *pDestBufPtr
++ = 0x2A; // *
764 *pDestBufPtr
++ = 0x48; // H
765 b116432Designator
= true;
770 if (pDestBufEnd
- pDestBufPtr
>= 4)
772 *pDestBufPtr
++ = 0x1B; // ESC
773 *pDestBufPtr
++ = 0x4E; // N
775 = static_cast< char >(0x20 + pCns116431992Data
[nOffset
++]);
777 = static_cast< char >(0x20 + pCns116431992Data
[nOffset
]);
787 switch (sal::detail::textenc::handleBadInputUnicodeToTextConversion(
788 bUndefined
, nChar
, nFlags
, &pDestBufPtr
, pDestBufEnd
,
789 &nInfo
, "\x0F" /* SI */, bSo
? 1 : 0, &bWritten
))
791 case sal::detail::textenc::BAD_INPUT_STOP
:
795 case sal::detail::textenc::BAD_INPUT_CONTINUE
:
801 case sal::detail::textenc::BAD_INPUT_NO_OUTPUT
:
808 nInfo
|= RTL_UNICODETOTEXT_INFO_DESTBUFFERTOSMALL
;
812 if ((nInfo
& (RTL_UNICODETOTEXT_INFO_ERROR
813 | RTL_UNICODETOTEXT_INFO_DESTBUFFERTOSMALL
))
817 if (nHighSurrogate
!= 0)
819 if ((nFlags
& RTL_UNICODETOTEXT_FLAGS_FLUSH
) != 0)
820 nInfo
|= RTL_UNICODETOTEXT_INFO_SRCBUFFERTOSMALL
;
822 switch (sal::detail::textenc::handleBadInputUnicodeToTextConversion(
823 false, 0, nFlags
, &pDestBufPtr
, pDestBufEnd
, &nInfo
,
824 "\x0F" /* SI */, bSo
? 1 : 0, &bWritten
))
826 case sal::detail::textenc::BAD_INPUT_STOP
:
831 case sal::detail::textenc::BAD_INPUT_CONTINUE
:
837 case sal::detail::textenc::BAD_INPUT_NO_OUTPUT
:
838 nInfo
|= RTL_UNICODETOTEXT_INFO_DESTBUFFERTOSMALL
;
842 if (bFlush
&& bSo
&& (nFlags
& RTL_UNICODETOTEXT_FLAGS_FLUSH
) != 0)
844 if (pDestBufPtr
!= pDestBufEnd
)
846 *pDestBufPtr
++ = 0x0F; // SI
850 nInfo
|= RTL_UNICODETOTEXT_INFO_DESTBUFFERTOSMALL
;
856 static_cast< ImplUnicodeToIso2022CnContext
* >(pContext
)->m_nHighSurrogate
858 static_cast< ImplUnicodeToIso2022CnContext
* >(pContext
)->m_eSoDesignator
860 static_cast< ImplUnicodeToIso2022CnContext
* >(pContext
)->m_b116432Designator
862 static_cast< ImplUnicodeToIso2022CnContext
* >(pContext
)->m_bSo
= bSo
;
867 *pSrcCvtChars
= nConverted
;
869 return pDestBufPtr
- pDestBuf
;
872 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */