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: tenchelp.h,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 #ifndef INCLUDED_RTL_TEXTENC_TENCHELP_H
32 #define INCLUDED_RTL_TEXTENC_TENCHELP_H
34 #include "rtl/tencinfo.h"
35 #include "rtl/textenc.h"
36 #include "sal/types.h"
38 #if defined __cplusplus
40 #endif /* __cplusplus */
42 #define RTL_TEXTCVT_BYTE_PRIVATE_START 0xF100
43 #define RTL_TEXTCVT_BYTE_PRIVATE_END 0xF1FF
45 /* ----------------- */
46 /* - TextConverter - */
47 /* ----------------- */
49 typedef void ImplTextConverterData
;
52 sal_Size (* ImplConvertToUnicodeProc
)(ImplTextConverterData
const * pData
,
54 sal_Char
const * pSrcBuf
,
56 sal_Unicode
* pDestBuf
,
60 sal_Size
* pSrcCvtBytes
);
63 sal_Size (* ImplConvertToTextProc
)(ImplTextConverterData
const * pData
,
65 sal_Unicode
const * pSrcBuf
,
71 sal_Size
* pSrcCvtChars
);
73 typedef void * (* ImplCreateTextContextProc
)(void);
75 typedef void (* ImplDestroyTextContextProc
)(void * pContext
);
77 typedef void (* ImplResetTextContextProc
)(void * pContext
);
79 typedef void * (* ImplCreateUnicodeContextProc
)(void);
81 typedef void (* ImplDestroyUnicodeContextProc
)(void * pContext
);
83 typedef void (* ImplResetUnicodeContextProc
)(void * pContext
);
87 ImplTextConverterData
const * mpConvertData
;
88 ImplConvertToUnicodeProc mpConvertTextToUnicodeProc
;
89 ImplConvertToTextProc mpConvertUnicodeToTextProc
;
90 ImplCreateTextContextProc mpCreateTextToUnicodeContext
;
91 ImplDestroyTextContextProc mpDestroyTextToUnicodeContext
;
92 ImplResetTextContextProc mpResetTextToUnicodeContext
;
93 ImplCreateUnicodeContextProc mpCreateUnicodeToTextContext
;
94 ImplDestroyUnicodeContextProc mpDestroyUnicodeToTextContext
;
95 ImplResetUnicodeContextProc mpResetUnicodeToTextContext
;
98 /* ----------------------------- */
99 /* - TextEncoding - Structures - */
100 /* ----------------------------- */
104 ImplTextConverter maConverter
;
105 sal_uInt8 mnMinCharSize
;
106 sal_uInt8 mnMaxCharSize
;
107 sal_uInt8 mnAveCharSize
;
108 sal_uInt8 mnBestWindowsCharset
;
109 char const * mpBestUnixCharset
;
110 char const * mpBestMimeCharset
;
111 sal_uInt32 mnInfoFlags
;
112 } ImplTextEncodingData
;
114 /* ----------------------------------- */
115 /* - TextConverter - Byte-Structures - */
116 /* ----------------------------------- */
120 sal_uInt16 mnUniChar
;
123 // to cater for mappings like MS1258 with 1--2 bytes per Unicode char,
125 } ImplUniCharTabData
;
129 const sal_uInt16
* mpToUniTab1
;
130 const sal_uInt16
* mpToUniTab2
;
131 sal_uChar mnToUniStart1
;
132 sal_uChar mnToUniEnd1
;
133 sal_uChar mnToUniStart2
;
134 sal_uChar mnToUniEnd2
;
135 const sal_uChar
* mpToCharTab1
;
136 const sal_uChar
* mpToCharTab2
;
137 const ImplUniCharTabData
* mpToCharExTab
;
138 sal_uInt16 mnToCharStart1
;
139 sal_uInt16 mnToCharEnd1
;
140 sal_uInt16 mnToCharStart2
;
141 sal_uInt16 mnToCharEnd2
;
142 sal_uInt16 mnToCharExCount
;
143 } ImplByteConvertData
;
145 /* ----------------------------------- */
146 /* - TextConverter - DBCS-Structures - */
147 /* ----------------------------------- */
151 sal_uChar mnLeadStart
;
153 sal_uChar mnTrail1Start
;
154 sal_uChar mnTrail1End
;
155 sal_uChar mnTrail2Start
;
156 sal_uChar mnTrail2End
;
157 sal_uChar mnTrail3Start
;
158 sal_uChar mnTrail3End
;
159 sal_uChar mnTrailCount
;
160 sal_uInt16 mnTrailRangeCount
;
161 sal_uInt16 mnUniStart
;
167 sal_uInt16 mnUniChar
;
168 sal_uInt8 mnTrailStart
;
169 sal_uInt8 mnTrailEnd
;
170 const sal_uInt16
* mpToUniTrailTab
;
171 } ImplDBCSToUniLeadTab
;
175 sal_uInt8 mnLowStart
;
177 const sal_uInt16
* mpToUniTrailTab
;
178 } ImplUniToDBCSHighTab
;
182 const ImplDBCSToUniLeadTab
* mpToUniLeadTab
;
183 const ImplUniToDBCSHighTab
* mpToDBCSHighTab
;
184 sal_uChar mnLeadStart
;
186 sal_uChar mnTrailStart
;
187 sal_uChar mnTrailEnd
;
188 const ImplDBCSEUDCData
* mpEUDCTab
;
189 sal_uInt16 mnEUDCCount
;
190 } ImplDBCSConvertData
;
192 /* ---------------------------------- */
193 /* - TextConverter - EUC-Structures - */
194 /* ---------------------------------- */
198 const ImplDBCSToUniLeadTab
* mpJIS0208ToUniLeadTab
;
199 const ImplDBCSToUniLeadTab
* mpJIS0212ToUniLeadTab
;
200 const ImplUniToDBCSHighTab
* mpUniToJIS0208HighTab
;
201 const ImplUniToDBCSHighTab
* mpUniToJIS0212HighTab
;
202 } ImplEUCJPConvertData
;
204 /* --------------------------------- */
205 /* - TextConverter - HelpFunctions - */
206 /* --------------------------------- */
208 sal_Unicode
ImplGetUndefinedUnicodeChar(sal_uChar cChar
, sal_uInt32 nFlags
);
211 ImplHandleUndefinedUnicodeToTextChar(ImplTextConverterData
const * pData
,
212 sal_Unicode
const ** ppSrcBuf
,
213 sal_Unicode
const * pEndSrcBuf
,
214 sal_Char
** ppDestBuf
,
215 sal_Char
const * pEndDestBuf
,
218 /* sal_True means 'continue,' sal_False means 'break' */
220 /* ----------------------------- */
221 /* - TextConverter - Functions - */
222 /* ----------------------------- */
224 sal_Size
ImplSymbolToUnicode( const ImplTextConverterData
* pData
, void* pContext
,
225 const sal_Char
* pSrcBuf
, sal_Size nSrcBytes
,
226 sal_Unicode
* pDestBuf
, sal_Size nDestChars
,
227 sal_uInt32 nFlags
, sal_uInt32
* pInfo
, sal_Size
* pSrcCvtBytes
);
228 sal_Size
ImplUnicodeToSymbol( const ImplTextConverterData
* pData
, void* pContext
,
229 const sal_Unicode
* pSrcBuf
, sal_Size nSrcChars
,
230 sal_Char
* pDestBuf
, sal_Size nDestBytes
,
231 sal_uInt32 nFlags
, sal_uInt32
* pInfo
, sal_Size
* pSrcCvtChars
);
232 sal_Size
ImplCharToUnicode( const ImplTextConverterData
* pData
, void* pContext
,
233 const sal_Char
* pSrcBuf
, sal_Size nSrcBytes
,
234 sal_Unicode
* pDestBuf
, sal_Size nDestChars
,
235 sal_uInt32 nFlags
, sal_uInt32
* pInfo
, sal_Size
* pSrcCvtBytes
);
236 sal_Size
ImplUnicodeToChar( const ImplTextConverterData
* pData
, void* pContext
,
237 const sal_Unicode
* pSrcBuf
, sal_Size nSrcChars
,
238 sal_Char
* pDestBuf
, sal_Size nDestBytes
,
239 sal_uInt32 nFlags
, sal_uInt32
* pInfo
, sal_Size
* pSrcCvtChars
);
240 sal_Size
ImplDBCSToUnicode( const ImplTextConverterData
* pData
, void* pContext
,
241 const sal_Char
* pSrcBuf
, sal_Size nSrcBytes
,
242 sal_Unicode
* pDestBuf
, sal_Size nDestChars
,
243 sal_uInt32 nFlags
, sal_uInt32
* pInfo
,
244 sal_Size
* pSrcCvtBytes
);
245 sal_Size
ImplUnicodeToDBCS( const ImplTextConverterData
* pData
, void* pContext
,
246 const sal_Unicode
* pSrcBuf
, sal_Size nSrcChars
,
247 sal_Char
* pDestBuf
, sal_Size nDestBytes
,
248 sal_uInt32 nFlags
, sal_uInt32
* pInfo
,
249 sal_Size
* pSrcCvtChars
);
250 sal_Size
ImplEUCJPToUnicode( const ImplTextConverterData
* pData
,
252 const sal_Char
* pSrcBuf
, sal_Size nSrcBytes
,
253 sal_Unicode
* pDestBuf
, sal_Size nDestChars
,
254 sal_uInt32 nFlags
, sal_uInt32
* pInfo
,
255 sal_Size
* pSrcCvtBytes
);
256 sal_Size
ImplUnicodeToEUCJP( const ImplTextConverterData
* pData
,
258 const sal_Unicode
* pSrcBuf
, sal_Size nSrcChars
,
259 sal_Char
* pDestBuf
, sal_Size nDestBytes
,
260 sal_uInt32 nFlags
, sal_uInt32
* pInfo
,
261 sal_Size
* pSrcCvtChars
);
262 void* ImplUTF7CreateUTF7TextToUnicodeContext( void );
263 void ImplUTF7DestroyTextToUnicodeContext( void* pContext
);
264 void ImplUTF7ResetTextToUnicodeContext( void* pContext
);
265 sal_Size
ImplUTF7ToUnicode( const ImplTextConverterData
* pData
, void* pContext
,
266 const sal_Char
* pSrcBuf
, sal_Size nSrcBytes
,
267 sal_Unicode
* pDestBuf
, sal_Size nDestChars
,
268 sal_uInt32 nFlags
, sal_uInt32
* pInfo
,
269 sal_Size
* pSrcCvtBytes
);
270 void* ImplUTF7CreateUnicodeToTextContext( void );
271 void ImplUTF7DestroyUnicodeToTextContext( void* pContext
);
272 void ImplUTF7ResetUnicodeToTextContext( void* pContext
);
273 sal_Size
ImplUnicodeToUTF7( const ImplTextConverterData
* pData
, void* pContext
,
274 const sal_Unicode
* pSrcBuf
, sal_Size nSrcChars
,
275 sal_Char
* pDestBuf
, sal_Size nDestBytes
,
276 sal_uInt32 nFlags
, sal_uInt32
* pInfo
,
277 sal_Size
* pSrcCvtChars
);
279 void * ImplCreateUtf8ToUnicodeContext(void) SAL_THROW_EXTERN_C();
280 void ImplResetUtf8ToUnicodeContext(void * pContext
) SAL_THROW_EXTERN_C();
281 sal_Size
ImplConvertUtf8ToUnicode(ImplTextConverterData
const * pData
,
282 void * pContext
, sal_Char
const * pSrcBuf
,
283 sal_Size nSrcBytes
, sal_Unicode
* pDestBuf
,
284 sal_Size nDestChars
, sal_uInt32 nFlags
,
285 sal_uInt32
* pInfo
, sal_Size
* pSrcCvtBytes
)
286 SAL_THROW_EXTERN_C();
287 void * ImplCreateUnicodeToUtf8Context(void) SAL_THROW_EXTERN_C();
288 void ImplResetUnicodeToUtf8Context(void * pContext
) SAL_THROW_EXTERN_C();
289 sal_Size
ImplConvertUnicodeToUtf8(ImplTextConverterData
const * pData
,
290 void * pContext
, sal_Unicode
const * pSrcBuf
,
291 sal_Size nSrcChars
, sal_Char
* pDestBuf
,
292 sal_Size nDestBytes
, sal_uInt32 nFlags
,
293 sal_uInt32
* pInfo
, sal_Size
* pSrcCvtChars
)
294 SAL_THROW_EXTERN_C();
296 #if defined __cplusplus
298 #endif /* __cplusplus */
300 #endif /* INCLUDED_RTL_TEXTENC_TENCHELP_H */