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