4.4. Character Set Conversion

const char * stringprep_locale_charset ( void) Find out system locale charset.

Note that this function return what it believe the SYSTEM is using as a locale, not what locale the program is currently in (modified, e.g., by a setlocale(LC_CTYPE, "ISO-8859-1")). The reason is that data read from argv[], stdin etc comes from the system, and is more likely to be encoded using the system locale than the program locale.

You can set the environment variable CHARSET to override the value returned. Note that this function caches the result, so you will have to modify CHARSET before calling (even indirectly) any stringprep functions, e.g., by setting it when invoking the application.

Return value: Return the character set used by the system locale. It will never return NULL, but use "ASCII" as a fallback.

char * stringprep_convert (const char * str, const char * to_codeset, const char * from_codeset) str: input zero-terminated string.

to_codeset: name of destination character set.

from_codeset: name of origin character set, as used by str.

Convert the string from one character set to another using the system's iconv() function.

Return value: Returns newly allocated zero-terminated string which is str transcoded into to_codeset.

char * stringprep_locale_to_utf8 (const char * str) str: input zero terminated string.

Convert string encoded in the locale's character set into UTF-8 by using stringprep_convert().

Return value: Returns newly allocated zero-terminated string which is str transcoded into UTF-8.

char * stringprep_utf8_to_locale (const char * str) str: input zero terminated string.

Convert string encoded in UTF-8 into the locale's character set by using stringprep_convert().

Return value: Returns newly allocated zero-terminated string which is str transcoded into the locale's character set.