source: branches/kmk/Lucide/plugins/ludoc/cpconv.h @ 339

Last change on this file since 339 was 337, checked in by dmik, 12 years ago

branches/kmk: Added a bunch of unicode conversion helpers based on the original propcnv() from lupoppler.cpp.

File size: 4.6 KB
Line 
1/* ***** BEGIN LICENSE BLOCK *****
2 * Version: CDDL 1.0/LGPL 2.1
3 *
4 * The contents of this file are subject to the COMMON DEVELOPMENT AND
5 * DISTRIBUTION LICENSE (CDDL) Version 1.0 (the "License"); you may not use
6 * this file except in compliance with the License. You may obtain a copy of
7 * the License at http://www.sun.com/cddl/
8 *
9 * Software distributed under the License is distributed on an "AS IS" basis,
10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11 * for the specific language governing rights and limitations under the
12 * License.
13 *
14 * The Initial Developer of the Original Code is
15 * Eugene Romanenko, netlabs.org.
16 * Portions created by the Initial Developer are Copyright (C) 2006
17 * the Initial Developer. All Rights Reserved.
18 *
19 * Contributor(s):
20 *
21 * Alternatively, the contents of this file may be used under the terms of
22 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
23 * in which case the provisions of the LGPL are applicable instead of those
24 * above. If you wish to allow use of your version of this file only under the
25 * terms of the LGPL, and not to allow others to use your version of this file
26 * under the terms of the CDDL, indicate your decision by deleting the
27 * provisions above and replace them with the notice and other provisions
28 * required by the LGPL. If you do not delete the provisions above, a recipient
29 * may use your version of this file under the terms of any one of the CDDL
30 * or the LGPL.
31 *
32 * ***** END LICENSE BLOCK ***** */
33
34
35#ifndef __cpconv_h
36#define __cpconv_h
37
38#include <unidef.h>
39#include <uconv.h>
40
41#ifdef __cplusplus
42extern "C" {
43#endif
44
45// Converts special non-ascii chars to suitable ascii chars
46VOID APIENTRY uniConvertSpChars( UniChar *uni );
47
48// Return number of chars which should be added to string
49// length to fit the string with converted ligatures.
50// If no ligatures in string - returns zero.
51LONG APIENTRY uniLigaturesLength( UniChar *str );
52
53// replaces ligatures in src into dst
54// src remains unchanged
55VOID APIENTRY uniReplaceLigatures( UniChar *src, UniChar *dst );
56
57// Converts the string from one encoding to another
58// the returned string is allocated with the new[] operator
59// if s is NULL, NULL is returned
60// both from and to must be valid encodings, otherwise the results are undefined
61// retLen may be NULL if the length of the returned buffer is not needed
62char *APIENTRY uniConvertString( const char *s, size_t len, UconvObject from,
63                                 UconvObject to, size_t *retLen );
64
65// Converts the string from UTF-16BE to the system encoding
66// the returned zero-terminated string is allocated with the new[] operator
67// if s is NULL, NULL is returned
68// if s starts with the Unicode marker (0xFE,FF) it is skipped
69// if utf16 or sys is NULL, a new temporary uconv object for the
70// corresponding encoding will be created
71// if utf16 or sys points to a null uconv object, the newly created object
72// will be returned there and must be freed with UniFreeUconvObject,
73// otherwise the passed in object will be used for the conversion
74char *APIENTRY uniUtf16BEToSys( const char *s, size_t len, UconvObject *utf16,
75                              UconvObject *sys );
76
77// The opposite to uniUtf16BEToSys
78char *APIENTRY uniSysToUtf16BE( const char *s, UconvObject *sys,
79                                UconvObject *utf16, size_t *retLen );
80
81// Same as uniUtf16BEToSys but converts UTF-16BE to UTF-8
82char *APIENTRY uniUtf16BEToUtf8( const char *s, size_t len, UconvObject *utf16,
83                                 UconvObject *utf8 );
84
85// The opposite to uniUtf16BEToUtf8
86char *APIENTRY uniUtf8ToUtf16BE( const char *s, UconvObject *utf8,
87                                 UconvObject *utf16, size_t *retLen );
88
89// Converts the zero-terminated string from UTF-8 to the system encoding
90// the returned zero-terminated string is allocated with the new[] operator
91// if s is NULL, NULL is returned
92// if s starts with the Unicode marker (0xFE,FF) it is skipped
93// if utf16 or sys is NULL, a new temporary uconv object for the
94// corresponding encoding will be created
95// if utf16 or sys points to a null uconv object, the newly created object
96// will be returned there and must be freed with UniFreeUconvObject,
97// otherwise the passed in object will be used for the conversion
98char *APIENTRY uniUtf8ToSys( const char *s, UconvObject *utf8,
99                             UconvObject *sys );
100
101// The opposite to uniUtf8ToSys
102char *APIENTRY uniSysToUtf8( const char *s, UconvObject *sys,
103                             UconvObject *utf8 );
104
105#ifdef __cplusplus
106}
107#endif
108
109#endif // __cpconv_h
Note: See TracBrowser for help on using the repository browser.