| 1 |
frodo |
181 |
/* |
| 2 |
|
|
unicode.h - Part of psiconv, a PSION 5 file formats converter |
| 3 |
frodo |
351 |
Copyright (c) 2003-2014 Frodo Looijaard <frodo@frodo.looijaard.name> |
| 4 |
frodo |
181 |
|
| 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 |
frodo |
217 |
#include <psiconv/buffer.h> |
| 26 |
frodo |
181 |
|
| 27 |
|
|
#ifdef __cplusplus |
| 28 |
|
|
extern "C" { |
| 29 |
|
|
#endif /* __cplusplus */ |
| 30 |
|
|
|
| 31 |
|
|
/* A simple unicode implementation, using UCS-2 (16-bit encoding). |
| 32 |
|
|
Unicode strings are arrays of psiconv_u16 characters, zero-terminated. |
| 33 |
|
|
Note that there is a lot in Unicode we do not support; for example, |
| 34 |
|
|
we assume a single Unicode codepoint corresponds with a single character. |
| 35 |
|
|
For EPOC, that should be enough */ |
| 36 |
|
|
|
| 37 |
|
|
extern int psiconv_unicode_select_characterset(const psiconv_config config, |
| 38 |
|
|
int charset); |
| 39 |
|
|
|
| 40 |
|
|
/* Translate a single character to a unicode character, using the |
| 41 |
|
|
translation tables in config */ |
| 42 |
frodo |
217 |
extern psiconv_ucs2 psiconv_unicode_read_char(const psiconv_config config, |
| 43 |
|
|
psiconv_buffer buf, |
| 44 |
|
|
int lev,psiconv_u32 off, |
| 45 |
|
|
int *length, |
| 46 |
|
|
int *status); |
| 47 |
frodo |
181 |
|
| 48 |
frodo |
217 |
extern int psiconv_unicode_write_char(const psiconv_config config, |
| 49 |
|
|
psiconv_buffer buf, |
| 50 |
|
|
int lev, |
| 51 |
|
|
psiconv_ucs2 value); |
| 52 |
frodo |
181 |
|
| 53 |
|
|
|
| 54 |
|
|
/* Compute the length of a unicode string */ |
| 55 |
|
|
extern int psiconv_unicode_strlen(const psiconv_ucs2 *input); |
| 56 |
|
|
|
| 57 |
frodo |
184 |
/* Duplicate a unicode string */ |
| 58 |
|
|
extern psiconv_ucs2 *psiconv_unicode_strdup(const psiconv_ucs2 *input); |
| 59 |
frodo |
181 |
|
| 60 |
frodo |
184 |
/* Compare two unicode strings. Ordering as in Unicode codepoints! */ |
| 61 |
frodo |
217 |
extern int psiconv_unicode_strcmp(const psiconv_ucs2 *str1, const psiconv_ucs2 *str2); |
| 62 |
frodo |
184 |
|
| 63 |
frodo |
217 |
/* Return a newly allocated empty string */ |
| 64 |
|
|
extern psiconv_ucs2 *psiconv_unicode_empty_string(void); |
| 65 |
|
|
|
| 66 |
frodo |
228 |
/* Convert a psiconv_list of psiconv_ucs2 characters to a string */ |
| 67 |
|
|
extern psiconv_ucs2 *psiconv_unicode_from_list(psiconv_list input); |
| 68 |
frodo |
217 |
|
| 69 |
frodo |
231 |
/* Look for needle in haystack, return pointer to found location */ |
| 70 |
frodo |
229 |
extern psiconv_ucs2 *psiconv_unicode_strstr(const psiconv_ucs2 *haystack, |
| 71 |
|
|
const psiconv_ucs2 *needle); |
| 72 |
frodo |
228 |
|
| 73 |
frodo |
229 |
|
| 74 |
frodo |
181 |
#ifdef __cplusplus |
| 75 |
|
|
} |
| 76 |
|
|
#endif /* __cplusplus */ |
| 77 |
|
|
|
| 78 |
|
|
#endif /* PSICONV_ERROR_H */ |