1 |
/* |
2 |
unicode.h - Part of psiconv, a PSION 5 file formats converter |
3 |
Copyright (c) 2003-2004 Frodo Looijaard <frodol@dds.nl> |
4 |
|
5 |
This program is free software; you can redistribute it and/or modify |
6 |
it under the terms of the GNU General Public License as published by |
7 |
the Free Software Foundation; either version 2 of the License, or |
8 |
(at your option) any later version. |
9 |
|
10 |
This program is distributed in the hope that it will be useful, |
11 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 |
GNU General Public License for more details. |
14 |
|
15 |
You should have received a copy of the GNU General Public License |
16 |
along with this program; if not, write to the Free Software |
17 |
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
18 |
*/ |
19 |
|
20 |
#ifndef PSICONV_UNICODE_H |
21 |
#define PSICONV_UNICODE_H |
22 |
|
23 |
#include <psiconv/general.h> |
24 |
#include <psiconv/configuration.h> |
25 |
|
26 |
#ifdef __cplusplus |
27 |
extern "C" { |
28 |
#endif /* __cplusplus */ |
29 |
|
30 |
/* A simple unicode implementation, using UCS-2 (16-bit encoding). |
31 |
Unicode strings are arrays of psiconv_u16 characters, zero-terminated. |
32 |
Note that there is a lot in Unicode we do not support; for example, |
33 |
we assume a single Unicode codepoint corresponds with a single character. |
34 |
For EPOC, that should be enough */ |
35 |
|
36 |
extern int psiconv_unicode_select_characterset(const psiconv_config config, |
37 |
int charset); |
38 |
|
39 |
/* Translate a single character to a unicode character, using the |
40 |
translation tables in config */ |
41 |
extern psiconv_ucs2 psiconv_unicode_from_char(const psiconv_config config, |
42 |
psiconv_u8 input); |
43 |
|
44 |
/* Translate a single unicode character to a normal character, using the |
45 |
translation tables in config */ |
46 |
extern psiconv_u8 psiconv_unicode_to_char(psiconv_config config, |
47 |
psiconv_ucs2 input); |
48 |
|
49 |
/* Translate a normal string to unicode. |
50 |
Output is allocated by this function on success, and must be freed by |
51 |
hand. */ |
52 |
extern int psiconv_unicode_from_chars(const psiconv_config config, |
53 |
const psiconv_u8 *input, |
54 |
psiconv_ucs2 **output); |
55 |
/* Translate a unicode string to a normal one. |
56 |
Output is allocated by this function on success, and must be freed by |
57 |
hand. */ |
58 |
extern int psiconv_unicode_to_chars(const psiconv_config config, |
59 |
const psiconv_ucs2 *input, |
60 |
psiconv_u8 **output); |
61 |
|
62 |
/* Compute the length of a unicode string */ |
63 |
extern int psiconv_unicode_strlen(const psiconv_ucs2 *input); |
64 |
|
65 |
/* Duplicate a unicode string */ |
66 |
extern psiconv_ucs2 *psiconv_unicode_strdup(const psiconv_ucs2 *input); |
67 |
|
68 |
/* Compare two unicode strings. Ordering as in Unicode codepoints! */ |
69 |
int psiconv_unicode_strcmp(const psiconv_ucs2 *str1, const psiconv_ucs2 *str2); |
70 |
|
71 |
#ifdef __cplusplus |
72 |
} |
73 |
#endif /* __cplusplus */ |
74 |
|
75 |
#endif /* PSICONV_ERROR_H */ |