1*9eab2a37SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*9eab2a37SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*9eab2a37SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*9eab2a37SAndrew Rist * distributed with this work for additional information 6*9eab2a37SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*9eab2a37SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*9eab2a37SAndrew Rist * "License"); you may not use this file except in compliance 9*9eab2a37SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*9eab2a37SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*9eab2a37SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*9eab2a37SAndrew Rist * software distributed under the License is distributed on an 15*9eab2a37SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*9eab2a37SAndrew Rist * KIND, either express or implied. See the License for the 17*9eab2a37SAndrew Rist * specific language governing permissions and limitations 18*9eab2a37SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*9eab2a37SAndrew Rist *************************************************************/ 21*9eab2a37SAndrew Rist 22*9eab2a37SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef INCLUDED_RTL_TEXTENC_TENCHELP_H 25cdf0e10cSrcweir #define INCLUDED_RTL_TEXTENC_TENCHELP_H 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include "rtl/tencinfo.h" 28cdf0e10cSrcweir #include "rtl/textenc.h" 29cdf0e10cSrcweir #include "sal/types.h" 30cdf0e10cSrcweir 31cdf0e10cSrcweir #if defined __cplusplus 32cdf0e10cSrcweir extern "C" { 33cdf0e10cSrcweir #endif /* __cplusplus */ 34cdf0e10cSrcweir 35cdf0e10cSrcweir #define RTL_TEXTCVT_BYTE_PRIVATE_START 0xF100 36cdf0e10cSrcweir #define RTL_TEXTCVT_BYTE_PRIVATE_END 0xF1FF 37cdf0e10cSrcweir 38cdf0e10cSrcweir /* ----------------- */ 39cdf0e10cSrcweir /* - TextConverter - */ 40cdf0e10cSrcweir /* ----------------- */ 41cdf0e10cSrcweir 42cdf0e10cSrcweir typedef void ImplTextConverterData; 43cdf0e10cSrcweir 44cdf0e10cSrcweir typedef 45cdf0e10cSrcweir sal_Size (* ImplConvertToUnicodeProc)(ImplTextConverterData const * pData, 46cdf0e10cSrcweir void * pContext, 47cdf0e10cSrcweir sal_Char const * pSrcBuf, 48cdf0e10cSrcweir sal_Size nSrcBytes, 49cdf0e10cSrcweir sal_Unicode * pDestBuf, 50cdf0e10cSrcweir sal_Size nDestChars, 51cdf0e10cSrcweir sal_uInt32 nFlags, 52cdf0e10cSrcweir sal_uInt32 * pInfo, 53cdf0e10cSrcweir sal_Size * pSrcCvtBytes); 54cdf0e10cSrcweir 55cdf0e10cSrcweir typedef 56cdf0e10cSrcweir sal_Size (* ImplConvertToTextProc)(ImplTextConverterData const * pData, 57cdf0e10cSrcweir void * pContext, 58cdf0e10cSrcweir sal_Unicode const * pSrcBuf, 59cdf0e10cSrcweir sal_Size nSrcChars, 60cdf0e10cSrcweir sal_Char * pDestBuf, 61cdf0e10cSrcweir sal_Size nDestBytes, 62cdf0e10cSrcweir sal_uInt32 nFlags, 63cdf0e10cSrcweir sal_uInt32 * pInfo, 64cdf0e10cSrcweir sal_Size * pSrcCvtChars); 65cdf0e10cSrcweir 66cdf0e10cSrcweir typedef void * (* ImplCreateTextContextProc)(void); 67cdf0e10cSrcweir 68cdf0e10cSrcweir typedef void (* ImplDestroyTextContextProc)(void * pContext); 69cdf0e10cSrcweir 70cdf0e10cSrcweir typedef void (* ImplResetTextContextProc)(void * pContext); 71cdf0e10cSrcweir 72cdf0e10cSrcweir typedef void * (* ImplCreateUnicodeContextProc)(void); 73cdf0e10cSrcweir 74cdf0e10cSrcweir typedef void (* ImplDestroyUnicodeContextProc)(void * pContext); 75cdf0e10cSrcweir 76cdf0e10cSrcweir typedef void (* ImplResetUnicodeContextProc)(void * pContext); 77cdf0e10cSrcweir 78cdf0e10cSrcweir typedef struct 79cdf0e10cSrcweir { 80cdf0e10cSrcweir ImplTextConverterData const * mpConvertData; 81cdf0e10cSrcweir ImplConvertToUnicodeProc mpConvertTextToUnicodeProc; 82cdf0e10cSrcweir ImplConvertToTextProc mpConvertUnicodeToTextProc; 83cdf0e10cSrcweir ImplCreateTextContextProc mpCreateTextToUnicodeContext; 84cdf0e10cSrcweir ImplDestroyTextContextProc mpDestroyTextToUnicodeContext; 85cdf0e10cSrcweir ImplResetTextContextProc mpResetTextToUnicodeContext; 86cdf0e10cSrcweir ImplCreateUnicodeContextProc mpCreateUnicodeToTextContext; 87cdf0e10cSrcweir ImplDestroyUnicodeContextProc mpDestroyUnicodeToTextContext; 88cdf0e10cSrcweir ImplResetUnicodeContextProc mpResetUnicodeToTextContext; 89cdf0e10cSrcweir } ImplTextConverter; 90cdf0e10cSrcweir 91cdf0e10cSrcweir /* ----------------------------- */ 92cdf0e10cSrcweir /* - TextEncoding - Structures - */ 93cdf0e10cSrcweir /* ----------------------------- */ 94cdf0e10cSrcweir 95cdf0e10cSrcweir typedef struct 96cdf0e10cSrcweir { 97cdf0e10cSrcweir ImplTextConverter maConverter; 98cdf0e10cSrcweir sal_uInt8 mnMinCharSize; 99cdf0e10cSrcweir sal_uInt8 mnMaxCharSize; 100cdf0e10cSrcweir sal_uInt8 mnAveCharSize; 101cdf0e10cSrcweir sal_uInt8 mnBestWindowsCharset; 102cdf0e10cSrcweir char const * mpBestUnixCharset; 103cdf0e10cSrcweir char const * mpBestMimeCharset; 104cdf0e10cSrcweir sal_uInt32 mnInfoFlags; 105cdf0e10cSrcweir } ImplTextEncodingData; 106cdf0e10cSrcweir 107cdf0e10cSrcweir /* ----------------------------------- */ 108cdf0e10cSrcweir /* - TextConverter - Byte-Structures - */ 109cdf0e10cSrcweir /* ----------------------------------- */ 110cdf0e10cSrcweir 111cdf0e10cSrcweir typedef struct 112cdf0e10cSrcweir { 113cdf0e10cSrcweir sal_uInt16 mnUniChar; 114cdf0e10cSrcweir sal_uChar mnChar; 115cdf0e10cSrcweir sal_uChar mnChar2; 116cdf0e10cSrcweir // to cater for mappings like MS1258 with 1--2 bytes per Unicode char, 117cdf0e10cSrcweir // 0 if unused 118cdf0e10cSrcweir } ImplUniCharTabData; 119cdf0e10cSrcweir 120cdf0e10cSrcweir typedef struct 121cdf0e10cSrcweir { 122cdf0e10cSrcweir const sal_uInt16* mpToUniTab1; 123cdf0e10cSrcweir const sal_uInt16* mpToUniTab2; 124cdf0e10cSrcweir sal_uChar mnToUniStart1; 125cdf0e10cSrcweir sal_uChar mnToUniEnd1; 126cdf0e10cSrcweir sal_uChar mnToUniStart2; 127cdf0e10cSrcweir sal_uChar mnToUniEnd2; 128cdf0e10cSrcweir const sal_uChar* mpToCharTab1; 129cdf0e10cSrcweir const sal_uChar* mpToCharTab2; 130cdf0e10cSrcweir const ImplUniCharTabData* mpToCharExTab; 131cdf0e10cSrcweir sal_uInt16 mnToCharStart1; 132cdf0e10cSrcweir sal_uInt16 mnToCharEnd1; 133cdf0e10cSrcweir sal_uInt16 mnToCharStart2; 134cdf0e10cSrcweir sal_uInt16 mnToCharEnd2; 135cdf0e10cSrcweir sal_uInt16 mnToCharExCount; 136cdf0e10cSrcweir } ImplByteConvertData; 137cdf0e10cSrcweir 138cdf0e10cSrcweir /* ----------------------------------- */ 139cdf0e10cSrcweir /* - TextConverter - DBCS-Structures - */ 140cdf0e10cSrcweir /* ----------------------------------- */ 141cdf0e10cSrcweir 142cdf0e10cSrcweir typedef struct 143cdf0e10cSrcweir { 144cdf0e10cSrcweir sal_uChar mnLeadStart; 145cdf0e10cSrcweir sal_uChar mnLeadEnd; 146cdf0e10cSrcweir sal_uChar mnTrail1Start; 147cdf0e10cSrcweir sal_uChar mnTrail1End; 148cdf0e10cSrcweir sal_uChar mnTrail2Start; 149cdf0e10cSrcweir sal_uChar mnTrail2End; 150cdf0e10cSrcweir sal_uChar mnTrail3Start; 151cdf0e10cSrcweir sal_uChar mnTrail3End; 152cdf0e10cSrcweir sal_uChar mnTrailCount; 153cdf0e10cSrcweir sal_uInt16 mnTrailRangeCount; 154cdf0e10cSrcweir sal_uInt16 mnUniStart; 155cdf0e10cSrcweir sal_uInt16 mnUniEnd; 156cdf0e10cSrcweir } ImplDBCSEUDCData; 157cdf0e10cSrcweir 158cdf0e10cSrcweir typedef struct 159cdf0e10cSrcweir { 160cdf0e10cSrcweir sal_uInt16 mnUniChar; 161cdf0e10cSrcweir sal_uInt8 mnTrailStart; 162cdf0e10cSrcweir sal_uInt8 mnTrailEnd; 163cdf0e10cSrcweir const sal_uInt16* mpToUniTrailTab; 164cdf0e10cSrcweir } ImplDBCSToUniLeadTab; 165cdf0e10cSrcweir 166cdf0e10cSrcweir typedef struct 167cdf0e10cSrcweir { 168cdf0e10cSrcweir sal_uInt8 mnLowStart; 169cdf0e10cSrcweir sal_uInt8 mnLowEnd; 170cdf0e10cSrcweir const sal_uInt16* mpToUniTrailTab; 171cdf0e10cSrcweir } ImplUniToDBCSHighTab; 172cdf0e10cSrcweir 173cdf0e10cSrcweir typedef struct 174cdf0e10cSrcweir { 175cdf0e10cSrcweir const ImplDBCSToUniLeadTab* mpToUniLeadTab; 176cdf0e10cSrcweir const ImplUniToDBCSHighTab* mpToDBCSHighTab; 177cdf0e10cSrcweir sal_uChar mnLeadStart; 178cdf0e10cSrcweir sal_uChar mnLeadEnd; 179cdf0e10cSrcweir sal_uChar mnTrailStart; 180cdf0e10cSrcweir sal_uChar mnTrailEnd; 181cdf0e10cSrcweir const ImplDBCSEUDCData* mpEUDCTab; 182cdf0e10cSrcweir sal_uInt16 mnEUDCCount; 183cdf0e10cSrcweir } ImplDBCSConvertData; 184cdf0e10cSrcweir 185cdf0e10cSrcweir /* ---------------------------------- */ 186cdf0e10cSrcweir /* - TextConverter - EUC-Structures - */ 187cdf0e10cSrcweir /* ---------------------------------- */ 188cdf0e10cSrcweir 189cdf0e10cSrcweir typedef struct 190cdf0e10cSrcweir { 191cdf0e10cSrcweir const ImplDBCSToUniLeadTab* mpJIS0208ToUniLeadTab; 192cdf0e10cSrcweir const ImplDBCSToUniLeadTab* mpJIS0212ToUniLeadTab; 193cdf0e10cSrcweir const ImplUniToDBCSHighTab* mpUniToJIS0208HighTab; 194cdf0e10cSrcweir const ImplUniToDBCSHighTab* mpUniToJIS0212HighTab; 195cdf0e10cSrcweir } ImplEUCJPConvertData; 196cdf0e10cSrcweir 197cdf0e10cSrcweir /* --------------------------------- */ 198cdf0e10cSrcweir /* - TextConverter - HelpFunctions - */ 199cdf0e10cSrcweir /* --------------------------------- */ 200cdf0e10cSrcweir 201cdf0e10cSrcweir sal_Unicode ImplGetUndefinedUnicodeChar(sal_uChar cChar, sal_uInt32 nFlags); 202cdf0e10cSrcweir 203cdf0e10cSrcweir sal_Bool 204cdf0e10cSrcweir ImplHandleUndefinedUnicodeToTextChar(ImplTextConverterData const * pData, 205cdf0e10cSrcweir sal_Unicode const ** ppSrcBuf, 206cdf0e10cSrcweir sal_Unicode const * pEndSrcBuf, 207cdf0e10cSrcweir sal_Char ** ppDestBuf, 208cdf0e10cSrcweir sal_Char const * pEndDestBuf, 209cdf0e10cSrcweir sal_uInt32 nFlags, 210cdf0e10cSrcweir sal_uInt32 * pInfo); 211cdf0e10cSrcweir /* sal_True means 'continue,' sal_False means 'break' */ 212cdf0e10cSrcweir 213cdf0e10cSrcweir /* ----------------------------- */ 214cdf0e10cSrcweir /* - TextConverter - Functions - */ 215cdf0e10cSrcweir /* ----------------------------- */ 216cdf0e10cSrcweir 217cdf0e10cSrcweir sal_Size ImplSymbolToUnicode( const ImplTextConverterData* pData, void* pContext, 218cdf0e10cSrcweir const sal_Char* pSrcBuf, sal_Size nSrcBytes, 219cdf0e10cSrcweir sal_Unicode* pDestBuf, sal_Size nDestChars, 220cdf0e10cSrcweir sal_uInt32 nFlags, sal_uInt32* pInfo, sal_Size* pSrcCvtBytes ); 221cdf0e10cSrcweir sal_Size ImplUnicodeToSymbol( const ImplTextConverterData* pData, void* pContext, 222cdf0e10cSrcweir const sal_Unicode* pSrcBuf, sal_Size nSrcChars, 223cdf0e10cSrcweir sal_Char* pDestBuf, sal_Size nDestBytes, 224cdf0e10cSrcweir sal_uInt32 nFlags, sal_uInt32* pInfo, sal_Size* pSrcCvtChars ); 225cdf0e10cSrcweir sal_Size ImplCharToUnicode( const ImplTextConverterData* pData, void* pContext, 226cdf0e10cSrcweir const sal_Char* pSrcBuf, sal_Size nSrcBytes, 227cdf0e10cSrcweir sal_Unicode* pDestBuf, sal_Size nDestChars, 228cdf0e10cSrcweir sal_uInt32 nFlags, sal_uInt32* pInfo, sal_Size* pSrcCvtBytes ); 229cdf0e10cSrcweir sal_Size ImplUnicodeToChar( const ImplTextConverterData* pData, void* pContext, 230cdf0e10cSrcweir const sal_Unicode* pSrcBuf, sal_Size nSrcChars, 231cdf0e10cSrcweir sal_Char* pDestBuf, sal_Size nDestBytes, 232cdf0e10cSrcweir sal_uInt32 nFlags, sal_uInt32* pInfo, sal_Size* pSrcCvtChars ); 233cdf0e10cSrcweir sal_Size ImplDBCSToUnicode( const ImplTextConverterData* pData, void* pContext, 234cdf0e10cSrcweir const sal_Char* pSrcBuf, sal_Size nSrcBytes, 235cdf0e10cSrcweir sal_Unicode* pDestBuf, sal_Size nDestChars, 236cdf0e10cSrcweir sal_uInt32 nFlags, sal_uInt32* pInfo, 237cdf0e10cSrcweir sal_Size* pSrcCvtBytes ); 238cdf0e10cSrcweir sal_Size ImplUnicodeToDBCS( const ImplTextConverterData* pData, void* pContext, 239cdf0e10cSrcweir const sal_Unicode* pSrcBuf, sal_Size nSrcChars, 240cdf0e10cSrcweir sal_Char* pDestBuf, sal_Size nDestBytes, 241cdf0e10cSrcweir sal_uInt32 nFlags, sal_uInt32* pInfo, 242cdf0e10cSrcweir sal_Size* pSrcCvtChars ); 243cdf0e10cSrcweir sal_Size ImplEUCJPToUnicode( const ImplTextConverterData* pData, 244cdf0e10cSrcweir void* pContext, 245cdf0e10cSrcweir const sal_Char* pSrcBuf, sal_Size nSrcBytes, 246cdf0e10cSrcweir sal_Unicode* pDestBuf, sal_Size nDestChars, 247cdf0e10cSrcweir sal_uInt32 nFlags, sal_uInt32* pInfo, 248cdf0e10cSrcweir sal_Size* pSrcCvtBytes ); 249cdf0e10cSrcweir sal_Size ImplUnicodeToEUCJP( const ImplTextConverterData* pData, 250cdf0e10cSrcweir void* pContext, 251cdf0e10cSrcweir const sal_Unicode* pSrcBuf, sal_Size nSrcChars, 252cdf0e10cSrcweir sal_Char* pDestBuf, sal_Size nDestBytes, 253cdf0e10cSrcweir sal_uInt32 nFlags, sal_uInt32* pInfo, 254cdf0e10cSrcweir sal_Size* pSrcCvtChars ); 255cdf0e10cSrcweir void* ImplUTF7CreateUTF7TextToUnicodeContext( void ); 256cdf0e10cSrcweir void ImplUTF7DestroyTextToUnicodeContext( void* pContext ); 257cdf0e10cSrcweir void ImplUTF7ResetTextToUnicodeContext( void* pContext ); 258cdf0e10cSrcweir sal_Size ImplUTF7ToUnicode( const ImplTextConverterData* pData, void* pContext, 259cdf0e10cSrcweir const sal_Char* pSrcBuf, sal_Size nSrcBytes, 260cdf0e10cSrcweir sal_Unicode* pDestBuf, sal_Size nDestChars, 261cdf0e10cSrcweir sal_uInt32 nFlags, sal_uInt32* pInfo, 262cdf0e10cSrcweir sal_Size* pSrcCvtBytes ); 263cdf0e10cSrcweir void* ImplUTF7CreateUnicodeToTextContext( void ); 264cdf0e10cSrcweir void ImplUTF7DestroyUnicodeToTextContext( void* pContext ); 265cdf0e10cSrcweir void ImplUTF7ResetUnicodeToTextContext( void* pContext ); 266cdf0e10cSrcweir sal_Size ImplUnicodeToUTF7( const ImplTextConverterData* pData, void* pContext, 267cdf0e10cSrcweir const sal_Unicode* pSrcBuf, sal_Size nSrcChars, 268cdf0e10cSrcweir sal_Char* pDestBuf, sal_Size nDestBytes, 269cdf0e10cSrcweir sal_uInt32 nFlags, sal_uInt32* pInfo, 270cdf0e10cSrcweir sal_Size* pSrcCvtChars ); 271cdf0e10cSrcweir 272cdf0e10cSrcweir void * ImplCreateUtf8ToUnicodeContext(void) SAL_THROW_EXTERN_C(); 273cdf0e10cSrcweir void ImplResetUtf8ToUnicodeContext(void * pContext) SAL_THROW_EXTERN_C(); 274cdf0e10cSrcweir sal_Size ImplConvertUtf8ToUnicode(ImplTextConverterData const * pData, 275cdf0e10cSrcweir void * pContext, sal_Char const * pSrcBuf, 276cdf0e10cSrcweir sal_Size nSrcBytes, sal_Unicode * pDestBuf, 277cdf0e10cSrcweir sal_Size nDestChars, sal_uInt32 nFlags, 278cdf0e10cSrcweir sal_uInt32 * pInfo, sal_Size * pSrcCvtBytes) 279cdf0e10cSrcweir SAL_THROW_EXTERN_C(); 280cdf0e10cSrcweir void * ImplCreateUnicodeToUtf8Context(void) SAL_THROW_EXTERN_C(); 281cdf0e10cSrcweir void ImplResetUnicodeToUtf8Context(void * pContext) SAL_THROW_EXTERN_C(); 282cdf0e10cSrcweir sal_Size ImplConvertUnicodeToUtf8(ImplTextConverterData const * pData, 283cdf0e10cSrcweir void * pContext, sal_Unicode const * pSrcBuf, 284cdf0e10cSrcweir sal_Size nSrcChars, sal_Char * pDestBuf, 285cdf0e10cSrcweir sal_Size nDestBytes, sal_uInt32 nFlags, 286cdf0e10cSrcweir sal_uInt32 * pInfo, sal_Size* pSrcCvtChars) 287cdf0e10cSrcweir SAL_THROW_EXTERN_C(); 288cdf0e10cSrcweir 289cdf0e10cSrcweir #if defined __cplusplus 290cdf0e10cSrcweir } 291cdf0e10cSrcweir #endif /* __cplusplus */ 292cdf0e10cSrcweir 293cdf0e10cSrcweir #endif /* INCLUDED_RTL_TEXTENC_TENCHELP_H */ 294