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