2010-10-27 07:13:11 -05:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2001-10-12 04:44:53 -05:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-10 06:32:53 -05:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2001-10-12 04:44:53 -05:00
|
|
|
*
|
2010-02-12 08:01:35 -06:00
|
|
|
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
2001-10-12 04:44:53 -05:00
|
|
|
*
|
2008-04-10 06:32:53 -05:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2001-10-12 04:44:53 -05:00
|
|
|
*
|
2008-04-10 06:32:53 -05:00
|
|
|
* This file is part of OpenOffice.org.
|
2001-10-12 04:44:53 -05:00
|
|
|
*
|
2008-04-10 06:32:53 -05:00
|
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
* only, as published by the Free Software Foundation.
|
2001-10-12 04:44:53 -05:00
|
|
|
*
|
2008-04-10 06:32:53 -05:00
|
|
|
* OpenOffice.org is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License version 3 for more details
|
|
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
2001-10-12 04:44:53 -05:00
|
|
|
*
|
2008-04-10 06:32:53 -05:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
|
|
* <http://www.openoffice.org/license.html>
|
|
|
|
* for a copy of the LGPLv3 License.
|
2001-10-12 04:44:53 -05:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
|
|
|
#include "converteuctw.h"
|
|
|
|
#include "context.h"
|
|
|
|
#include "converter.h"
|
|
|
|
#include "tenchelp.h"
|
2001-10-17 08:28:23 -05:00
|
|
|
#include "unichars.h"
|
2001-10-12 04:44:53 -05:00
|
|
|
#include "rtl/alloc.h"
|
|
|
|
#include "rtl/textcvt.h"
|
|
|
|
#include "sal/types.h"
|
|
|
|
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
IMPL_EUC_TW_TO_UNICODE_STATE_0,
|
|
|
|
IMPL_EUC_TW_TO_UNICODE_STATE_1,
|
|
|
|
IMPL_EUC_TW_TO_UNICODE_STATE_2_1,
|
|
|
|
IMPL_EUC_TW_TO_UNICODE_STATE_2_2,
|
|
|
|
IMPL_EUC_TW_TO_UNICODE_STATE_2_3
|
|
|
|
} ImplEucTwToUnicodeState;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
ImplEucTwToUnicodeState m_eState;
|
|
|
|
sal_Int32 m_nPlane; /* 0--15 */
|
|
|
|
sal_Int32 m_nRow; /* 0--93 */
|
|
|
|
} ImplEucTwToUnicodeContext;
|
|
|
|
|
|
|
|
void * ImplCreateEucTwToUnicodeContext(void)
|
|
|
|
{
|
|
|
|
void * pContext = rtl_allocateMemory(sizeof (ImplEucTwToUnicodeContext));
|
|
|
|
((ImplEucTwToUnicodeContext *) pContext)->m_eState
|
|
|
|
= IMPL_EUC_TW_TO_UNICODE_STATE_0;
|
|
|
|
return pContext;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ImplResetEucTwToUnicodeContext(void * pContext)
|
|
|
|
{
|
|
|
|
if (pContext)
|
|
|
|
((ImplEucTwToUnicodeContext *) pContext)->m_eState
|
|
|
|
= IMPL_EUC_TW_TO_UNICODE_STATE_0;
|
|
|
|
}
|
|
|
|
|
|
|
|
sal_Size ImplConvertEucTwToUnicode(ImplTextConverterData const * pData,
|
|
|
|
void * pContext,
|
|
|
|
sal_Char const * pSrcBuf,
|
|
|
|
sal_Size nSrcBytes,
|
|
|
|
sal_Unicode * pDestBuf,
|
|
|
|
sal_Size nDestChars,
|
|
|
|
sal_uInt32 nFlags,
|
|
|
|
sal_uInt32 * pInfo,
|
|
|
|
sal_Size * pSrcCvtBytes)
|
|
|
|
{
|
2001-10-17 08:28:23 -05:00
|
|
|
sal_uInt16 const * pCns116431992Data
|
2001-10-12 04:44:53 -05:00
|
|
|
= ((ImplEucTwConverterData const *) pData)->
|
|
|
|
m_pCns116431992ToUnicodeData;
|
|
|
|
sal_Int32 const * pCns116431992RowOffsets
|
|
|
|
= ((ImplEucTwConverterData const *) pData)->
|
|
|
|
m_pCns116431992ToUnicodeRowOffsets;
|
|
|
|
sal_Int32 const * pCns116431992PlaneOffsets
|
|
|
|
= ((ImplEucTwConverterData const *) pData)->
|
|
|
|
m_pCns116431992ToUnicodePlaneOffsets;
|
|
|
|
ImplEucTwToUnicodeState eState = IMPL_EUC_TW_TO_UNICODE_STATE_0;
|
2004-02-04 06:50:35 -06:00
|
|
|
sal_Int32 nPlane = 0;
|
|
|
|
sal_Int32 nRow = 0;
|
2001-10-12 04:44:53 -05:00
|
|
|
sal_uInt32 nInfo = 0;
|
|
|
|
sal_Size nConverted = 0;
|
|
|
|
sal_Unicode * pDestBufPtr = pDestBuf;
|
|
|
|
sal_Unicode * pDestBufEnd = pDestBuf + nDestChars;
|
|
|
|
|
|
|
|
if (pContext)
|
|
|
|
{
|
|
|
|
eState = ((ImplEucTwToUnicodeContext *) pContext)->m_eState;
|
|
|
|
nPlane = ((ImplEucTwToUnicodeContext *) pContext)->m_nPlane;
|
|
|
|
nRow = ((ImplEucTwToUnicodeContext *) pContext)->m_nRow;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (; nConverted < nSrcBytes; ++nConverted)
|
|
|
|
{
|
|
|
|
sal_Bool bUndefined = sal_True;
|
2005-01-27 04:14:46 -06:00
|
|
|
sal_uInt32 nChar = *(sal_uChar const *) pSrcBuf++;
|
2001-10-12 04:44:53 -05:00
|
|
|
switch (eState)
|
|
|
|
{
|
|
|
|
case IMPL_EUC_TW_TO_UNICODE_STATE_0:
|
|
|
|
if (nChar < 0x80)
|
|
|
|
if (pDestBufPtr != pDestBufEnd)
|
|
|
|
*pDestBufPtr++ = (sal_Unicode) nChar;
|
|
|
|
else
|
|
|
|
goto no_output;
|
|
|
|
else if (nChar >= 0xA1 && nChar <= 0xFE)
|
|
|
|
{
|
|
|
|
nRow = nChar - 0xA1;
|
|
|
|
eState = IMPL_EUC_TW_TO_UNICODE_STATE_1;
|
|
|
|
}
|
|
|
|
else if (nChar == 0x8E)
|
|
|
|
eState = IMPL_EUC_TW_TO_UNICODE_STATE_2_1;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
bUndefined = sal_False;
|
|
|
|
goto bad_input;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IMPL_EUC_TW_TO_UNICODE_STATE_1:
|
|
|
|
if (nChar >= 0xA1 && nChar <= 0xFE)
|
|
|
|
{
|
2001-10-17 08:28:23 -05:00
|
|
|
nPlane = 0;
|
|
|
|
goto transform;
|
2001-10-12 04:44:53 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
bUndefined = sal_False;
|
|
|
|
goto bad_input;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IMPL_EUC_TW_TO_UNICODE_STATE_2_1:
|
|
|
|
if (nChar >= 0xA1 && nChar <= 0xB0)
|
|
|
|
{
|
|
|
|
nPlane = nChar - 0xA1;
|
|
|
|
++eState;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
bUndefined = sal_False;
|
|
|
|
goto bad_input;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IMPL_EUC_TW_TO_UNICODE_STATE_2_2:
|
|
|
|
if (nChar >= 0xA1 && nChar <= 0xFE)
|
|
|
|
{
|
|
|
|
nRow = nChar - 0xA1;
|
|
|
|
++eState;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
bUndefined = sal_False;
|
|
|
|
goto bad_input;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IMPL_EUC_TW_TO_UNICODE_STATE_2_3:
|
|
|
|
if (nChar >= 0xA1 && nChar <= 0xFE)
|
2001-10-17 08:28:23 -05:00
|
|
|
goto transform;
|
|
|
|
else
|
2001-10-12 04:44:53 -05:00
|
|
|
{
|
2001-10-17 08:28:23 -05:00
|
|
|
bUndefined = sal_False;
|
|
|
|
goto bad_input;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
|
|
|
|
transform:
|
|
|
|
{
|
|
|
|
sal_Int32 nPlaneOffset = pCns116431992PlaneOffsets[nPlane];
|
|
|
|
if (nPlaneOffset == -1)
|
|
|
|
goto bad_input;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sal_Int32 nOffset
|
|
|
|
= pCns116431992RowOffsets[nPlaneOffset + nRow];
|
|
|
|
if (nOffset == -1)
|
2001-10-12 04:44:53 -05:00
|
|
|
goto bad_input;
|
|
|
|
else
|
|
|
|
{
|
2001-10-17 08:28:23 -05:00
|
|
|
sal_uInt32 nFirstLast = pCns116431992Data[nOffset++];
|
|
|
|
sal_uInt32 nFirst = nFirstLast & 0xFF;
|
|
|
|
sal_uInt32 nLast = nFirstLast >> 8;
|
|
|
|
nChar -= 0xA0;
|
|
|
|
if (nChar >= nFirst && nChar <= nLast)
|
2001-10-12 04:44:53 -05:00
|
|
|
{
|
2001-10-17 08:28:23 -05:00
|
|
|
sal_uInt32 nUnicode
|
|
|
|
= pCns116431992Data[nOffset + (nChar - nFirst)];
|
2001-10-12 04:44:53 -05:00
|
|
|
if (nUnicode == 0xFFFF)
|
|
|
|
goto bad_input;
|
2001-10-17 08:28:23 -05:00
|
|
|
else if (ImplIsHighSurrogate(nUnicode))
|
2001-10-12 04:44:53 -05:00
|
|
|
if (pDestBufEnd - pDestBufPtr >= 2)
|
|
|
|
{
|
2001-10-17 08:28:23 -05:00
|
|
|
nOffset += nLast - nFirst + 1;
|
|
|
|
nFirst = pCns116431992Data[nOffset++];
|
|
|
|
*pDestBufPtr++ = (sal_Unicode) nUnicode;
|
2001-10-12 04:44:53 -05:00
|
|
|
*pDestBufPtr++
|
2001-10-17 08:28:23 -05:00
|
|
|
= (sal_Unicode)
|
|
|
|
pCns116431992Data[
|
|
|
|
nOffset + (nChar - nFirst)];
|
2001-10-12 04:44:53 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
goto no_output;
|
2001-10-17 08:28:23 -05:00
|
|
|
else
|
|
|
|
if (pDestBufPtr != pDestBufEnd)
|
|
|
|
*pDestBufPtr++ = (sal_Unicode) nUnicode;
|
|
|
|
else
|
|
|
|
goto no_output;
|
2001-10-12 04:44:53 -05:00
|
|
|
}
|
2001-10-17 08:28:23 -05:00
|
|
|
else
|
|
|
|
goto bad_input;
|
|
|
|
eState = IMPL_EUC_TW_TO_UNICODE_STATE_0;
|
2001-10-12 04:44:53 -05:00
|
|
|
}
|
|
|
|
}
|
2001-10-17 08:28:23 -05:00
|
|
|
continue;
|
2001-10-12 04:44:53 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
bad_input:
|
2004-06-17 05:41:18 -05:00
|
|
|
switch (ImplHandleBadInputTextToUnicodeConversion(
|
|
|
|
bUndefined, sal_True, 0, nFlags, &pDestBufPtr, pDestBufEnd,
|
|
|
|
&nInfo))
|
2001-10-12 04:44:53 -05:00
|
|
|
{
|
|
|
|
case IMPL_BAD_INPUT_STOP:
|
|
|
|
eState = IMPL_EUC_TW_TO_UNICODE_STATE_0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IMPL_BAD_INPUT_CONTINUE:
|
|
|
|
eState = IMPL_EUC_TW_TO_UNICODE_STATE_0;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case IMPL_BAD_INPUT_NO_OUTPUT:
|
|
|
|
goto no_output;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
no_output:
|
|
|
|
--pSrcBuf;
|
|
|
|
nInfo |= RTL_TEXTTOUNICODE_INFO_DESTBUFFERTOSMALL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (eState != IMPL_EUC_TW_TO_UNICODE_STATE_0
|
|
|
|
&& (nInfo & (RTL_TEXTTOUNICODE_INFO_ERROR
|
|
|
|
| RTL_TEXTTOUNICODE_INFO_DESTBUFFERTOSMALL))
|
|
|
|
== 0)
|
2006-06-19 22:36:41 -05:00
|
|
|
{
|
2001-10-12 04:44:53 -05:00
|
|
|
if ((nFlags & RTL_TEXTTOUNICODE_FLAGS_FLUSH) == 0)
|
|
|
|
nInfo |= RTL_TEXTTOUNICODE_INFO_SRCBUFFERTOSMALL;
|
|
|
|
else
|
2004-06-17 05:41:18 -05:00
|
|
|
switch (ImplHandleBadInputTextToUnicodeConversion(
|
|
|
|
sal_False, sal_True, 0, nFlags, &pDestBufPtr,
|
|
|
|
pDestBufEnd, &nInfo))
|
2001-10-12 04:44:53 -05:00
|
|
|
{
|
|
|
|
case IMPL_BAD_INPUT_STOP:
|
|
|
|
case IMPL_BAD_INPUT_CONTINUE:
|
|
|
|
eState = IMPL_EUC_TW_TO_UNICODE_STATE_0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IMPL_BAD_INPUT_NO_OUTPUT:
|
|
|
|
nInfo |= RTL_TEXTTOUNICODE_INFO_DESTBUFFERTOSMALL;
|
|
|
|
break;
|
|
|
|
}
|
2006-06-19 22:36:41 -05:00
|
|
|
}
|
2001-10-12 04:44:53 -05:00
|
|
|
|
|
|
|
if (pContext)
|
|
|
|
{
|
|
|
|
((ImplEucTwToUnicodeContext *) pContext)->m_eState = eState;
|
|
|
|
((ImplEucTwToUnicodeContext *) pContext)->m_nPlane = nPlane;
|
|
|
|
((ImplEucTwToUnicodeContext *) pContext)->m_nRow = nRow;
|
|
|
|
}
|
|
|
|
if (pInfo)
|
|
|
|
*pInfo = nInfo;
|
|
|
|
if (pSrcCvtBytes)
|
|
|
|
*pSrcCvtBytes = nConverted;
|
|
|
|
|
|
|
|
return pDestBufPtr - pDestBuf;
|
|
|
|
}
|
|
|
|
|
|
|
|
sal_Size ImplConvertUnicodeToEucTw(ImplTextConverterData const * pData,
|
|
|
|
void * pContext,
|
|
|
|
sal_Unicode const * pSrcBuf,
|
|
|
|
sal_Size nSrcChars,
|
|
|
|
sal_Char * pDestBuf,
|
|
|
|
sal_Size nDestBytes,
|
|
|
|
sal_uInt32 nFlags,
|
|
|
|
sal_uInt32 * pInfo,
|
|
|
|
sal_Size * pSrcCvtChars)
|
|
|
|
{
|
2001-10-17 08:28:23 -05:00
|
|
|
sal_uInt8 const * pCns116431992Data
|
2001-10-12 04:44:53 -05:00
|
|
|
= ((ImplEucTwConverterData const *) pData)->
|
|
|
|
m_pUnicodeToCns116431992Data;
|
|
|
|
sal_Int32 const * pCns116431992PageOffsets
|
|
|
|
= ((ImplEucTwConverterData const *) pData)->
|
|
|
|
m_pUnicodeToCns116431992PageOffsets;
|
|
|
|
sal_Int32 const * pCns116431992PlaneOffsets
|
|
|
|
= ((ImplEucTwConverterData const *) pData)->
|
|
|
|
m_pUnicodeToCns116431992PlaneOffsets;
|
|
|
|
sal_Unicode nHighSurrogate = 0;
|
|
|
|
sal_uInt32 nInfo = 0;
|
|
|
|
sal_Size nConverted = 0;
|
|
|
|
sal_Char * pDestBufPtr = pDestBuf;
|
|
|
|
sal_Char * pDestBufEnd = pDestBuf + nDestBytes;
|
|
|
|
|
|
|
|
if (pContext)
|
|
|
|
nHighSurrogate
|
|
|
|
= ((ImplUnicodeToTextContext *) pContext)->m_nHighSurrogate;
|
|
|
|
|
|
|
|
for (; nConverted < nSrcChars; ++nConverted)
|
|
|
|
{
|
|
|
|
sal_Bool bUndefined = sal_True;
|
|
|
|
sal_uInt32 nChar = *pSrcBuf++;
|
|
|
|
if (nHighSurrogate == 0)
|
2001-10-17 08:28:23 -05:00
|
|
|
{
|
|
|
|
if (ImplIsHighSurrogate(nChar))
|
2001-10-12 04:44:53 -05:00
|
|
|
{
|
2001-10-17 08:28:23 -05:00
|
|
|
nHighSurrogate = (sal_Unicode) nChar;
|
|
|
|
continue;
|
2001-10-12 04:44:53 -05:00
|
|
|
}
|
2001-10-17 08:28:23 -05:00
|
|
|
}
|
|
|
|
else if (ImplIsLowSurrogate(nChar))
|
|
|
|
nChar = ImplCombineSurrogates(nHighSurrogate, nChar);
|
2001-10-12 04:44:53 -05:00
|
|
|
else
|
2001-10-17 08:28:23 -05:00
|
|
|
{
|
|
|
|
bUndefined = sal_False;
|
|
|
|
goto bad_input;
|
|
|
|
}
|
2001-10-12 04:44:53 -05:00
|
|
|
|
2001-10-17 08:28:23 -05:00
|
|
|
if (ImplIsLowSurrogate(nChar) || ImplIsNoncharacter(nChar))
|
|
|
|
{
|
|
|
|
bUndefined = sal_False;
|
|
|
|
goto bad_input;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nChar < 0x80)
|
|
|
|
if (pDestBufPtr != pDestBufEnd)
|
|
|
|
*pDestBufPtr++ = (sal_Char) nChar;
|
|
|
|
else
|
|
|
|
goto no_output;
|
|
|
|
else
|
2001-10-12 04:44:53 -05:00
|
|
|
{
|
|
|
|
sal_Int32 nOffset = pCns116431992PlaneOffsets[nChar >> 16];
|
2001-10-17 08:28:23 -05:00
|
|
|
sal_uInt32 nFirst;
|
|
|
|
sal_uInt32 nLast;
|
2001-10-12 04:44:53 -05:00
|
|
|
sal_uInt32 nPlane;
|
|
|
|
if (nOffset == -1)
|
|
|
|
goto bad_input;
|
|
|
|
nOffset
|
|
|
|
= pCns116431992PageOffsets[nOffset + ((nChar & 0xFF00) >> 8)];
|
|
|
|
if (nOffset == -1)
|
|
|
|
goto bad_input;
|
2001-10-17 08:28:23 -05:00
|
|
|
nFirst = pCns116431992Data[nOffset++];
|
|
|
|
nLast = pCns116431992Data[nOffset++];
|
|
|
|
nChar &= 0xFF;
|
|
|
|
if (nChar < nFirst || nChar > nLast)
|
|
|
|
goto bad_input;
|
|
|
|
nOffset += 3 * (nChar - nFirst);
|
|
|
|
nPlane = pCns116431992Data[nOffset++];
|
|
|
|
if (nPlane == 0)
|
2001-10-12 04:44:53 -05:00
|
|
|
goto bad_input;
|
|
|
|
if (pDestBufEnd - pDestBufPtr < (nPlane == 1 ? 2 : 4))
|
|
|
|
goto no_output;
|
|
|
|
if (nPlane != 1)
|
|
|
|
{
|
2006-06-19 22:36:41 -05:00
|
|
|
*pDestBufPtr++ = (sal_Char) (unsigned char) 0x8E;
|
2001-10-12 04:44:53 -05:00
|
|
|
*pDestBufPtr++ = (sal_Char) (0xA0 + nPlane);
|
|
|
|
}
|
2001-10-17 08:28:23 -05:00
|
|
|
*pDestBufPtr++ = (sal_Char) (0xA0 + pCns116431992Data[nOffset++]);
|
|
|
|
*pDestBufPtr++ = (sal_Char) (0xA0 + pCns116431992Data[nOffset]);
|
2001-10-12 04:44:53 -05:00
|
|
|
}
|
2001-10-17 08:28:23 -05:00
|
|
|
nHighSurrogate = 0;
|
2001-10-12 04:44:53 -05:00
|
|
|
continue;
|
|
|
|
|
|
|
|
bad_input:
|
|
|
|
switch (ImplHandleBadInputUnicodeToTextConversion(bUndefined,
|
2001-10-17 08:28:23 -05:00
|
|
|
nChar,
|
2001-10-12 04:44:53 -05:00
|
|
|
nFlags,
|
|
|
|
&pDestBufPtr,
|
|
|
|
pDestBufEnd,
|
2001-11-19 10:46:37 -06:00
|
|
|
&nInfo,
|
|
|
|
NULL,
|
|
|
|
0,
|
|
|
|
NULL))
|
2001-10-12 04:44:53 -05:00
|
|
|
{
|
|
|
|
case IMPL_BAD_INPUT_STOP:
|
|
|
|
nHighSurrogate = 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IMPL_BAD_INPUT_CONTINUE:
|
|
|
|
nHighSurrogate = 0;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case IMPL_BAD_INPUT_NO_OUTPUT:
|
|
|
|
goto no_output;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
no_output:
|
|
|
|
--pSrcBuf;
|
|
|
|
nInfo |= RTL_UNICODETOTEXT_INFO_DESTBUFFERTOSMALL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nHighSurrogate != 0
|
|
|
|
&& (nInfo & (RTL_UNICODETOTEXT_INFO_ERROR
|
|
|
|
| RTL_UNICODETOTEXT_INFO_DESTBUFFERTOSMALL))
|
|
|
|
== 0)
|
2006-06-19 22:36:41 -05:00
|
|
|
{
|
2001-10-12 04:44:53 -05:00
|
|
|
if ((nFlags & RTL_UNICODETOTEXT_FLAGS_FLUSH) != 0)
|
|
|
|
nInfo |= RTL_UNICODETOTEXT_INFO_SRCBUFFERTOSMALL;
|
|
|
|
else
|
|
|
|
switch (ImplHandleBadInputUnicodeToTextConversion(sal_False,
|
2001-10-17 08:28:23 -05:00
|
|
|
0,
|
2001-10-12 04:44:53 -05:00
|
|
|
nFlags,
|
|
|
|
&pDestBufPtr,
|
|
|
|
pDestBufEnd,
|
2001-11-19 10:46:37 -06:00
|
|
|
&nInfo,
|
|
|
|
NULL,
|
|
|
|
0,
|
|
|
|
NULL))
|
2001-10-12 04:44:53 -05:00
|
|
|
{
|
|
|
|
case IMPL_BAD_INPUT_STOP:
|
|
|
|
case IMPL_BAD_INPUT_CONTINUE:
|
|
|
|
nHighSurrogate = 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IMPL_BAD_INPUT_NO_OUTPUT:
|
|
|
|
nInfo |= RTL_UNICODETOTEXT_INFO_DESTBUFFERTOSMALL;
|
|
|
|
break;
|
|
|
|
}
|
2006-06-19 22:36:41 -05:00
|
|
|
}
|
2001-10-12 04:44:53 -05:00
|
|
|
|
|
|
|
if (pContext)
|
|
|
|
((ImplUnicodeToTextContext *) pContext)->m_nHighSurrogate
|
|
|
|
= nHighSurrogate;
|
|
|
|
if (pInfo)
|
|
|
|
*pInfo = nInfo;
|
|
|
|
if (pSrcCvtChars)
|
|
|
|
*pSrcCvtChars = nConverted;
|
|
|
|
|
|
|
|
return pDestBufPtr - pDestBuf;
|
|
|
|
}
|
2010-10-27 07:13:11 -05:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|