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