You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

77 lines
2.7KB

  1. /*
  2. Character encoding transformation - basics header
  3. Copyright (C) 2005-2008 Olaf Klein, o.b.klein@gpsbabel.org
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 USA
  15. */
  16. #ifndef CET_H
  17. #define CET_H
  18. #define CET_ERROR 1
  19. #define CET_SUCCESS 0
  20. typedef struct cet_ucs4_link_s {
  21. int value; /* UCS-4 value */
  22. short origin; /* associeted character */
  23. } cet_ucs4_link_t;
  24. typedef struct cet_cs_vec_s {
  25. const char* name; /* name of character set */
  26. const char** alias; /* alias table */
  27. struct cet_cs_vec_s* fallback; /* fallback character set */
  28. void* unused;
  29. const int* ucs4_map; /* char to UCS-4 value table */
  30. const int ucs4_offset; /* first non standard character */
  31. const int ucs4_count; /* values in table */
  32. const cet_ucs4_link_t* ucs4_link; /* UCS-4 to char backward links */
  33. const int ucs4_links; /* number of links */
  34. const cet_ucs4_link_t* ucs4_extra; /* Non standard UCS-4 to ... */
  35. const int ucs4_extras; /* number of extra links */
  36. struct cet_cs_vec_s* next;
  37. } cet_cs_vec_t;
  38. /* single char/value transmission */
  39. int cet_utf8_to_ucs4(const char* str, int* bytes, int* value);
  40. int cet_ucs4_to_utf8(char* dest, size_t dest_size, int value);
  41. /* single char/value transmission - vec based */
  42. int cet_char_to_ucs4(const char src, const cet_cs_vec_t* vec, int* value);
  43. short cet_utf8_to_char(const char* str, const cet_cs_vec_t* vecint, int* bytes, int* value);
  44. short cet_ucs4_to_char(const int value, const cet_cs_vec_t* vec);
  45. /* string to string - vector based */
  46. char* cet_str_utf8_to_any(const char* src, const cet_cs_vec_t* vec);
  47. char* cet_str_any_to_utf8(const char* src, const cet_cs_vec_t* vec);
  48. char* cet_str_uni_to_utf8(const short* src, const int length);
  49. /* UTF-8 string manipulation functions */
  50. unsigned int cet_utf8_strlen(const char* str);
  51. char* cet_utf8_strdup(const char* str);
  52. char* cet_utf8_strndup(const char* str, const int maxlen);
  53. /* unicode functions */
  54. short* cet_str_any_to_uni(const char* src, const cet_cs_vec_t* vec, int* length);
  55. #endif