utf8.h 816 B

12345678910111213141516171819202122232425
  1. #ifndef SHARE__UTF8_H
  2. #define SHARE__UTF8_H
  3. /*
  4. * Convert a string between UTF-8 and the locale's charset.
  5. * Invalid bytes are replaced by '#', and characters that are
  6. * not available in the target encoding are replaced by '?'.
  7. *
  8. * If the locale's charset is not set explicitly then it is
  9. * obtained using nl_langinfo(CODESET), where available, the
  10. * environment variable CHARSET, or assumed to be US-ASCII.
  11. *
  12. * Return value of conversion functions:
  13. *
  14. * -1 : memory allocation failed
  15. * 0 : data was converted exactly
  16. * 1 : valid data was converted approximately (using '?')
  17. * 2 : input was invalid (but still converted, using '#')
  18. * 3 : unknown encoding (but still converted, using '?')
  19. */
  20. int utf8_encode(const char *from, char **to);
  21. int utf8_decode(const char *from, char **to);
  22. #endif