1 /* Encoding utility from UTF-8 to locale and vice versa
2 Copyright (C) 2001, 2002 Peter Verthez
4 Permission granted to do anything with this file that you want, as long
5 as the above copyright is retained in all copies.
6 THERE IS NO WARRANTY - USE AT YOUR OWN RISK
15 #include "libcharset.h"
17 static convert_t locale_conv = NULL;
19 void convert_set_unknown(const char* unknown)
21 conversion_set_unknown(locale_conv, unknown);
24 void close_conversion_contexts()
26 cleanup_utf8_conversion(locale_conv);
29 int open_conversion_contexts()
31 assert (locale_conv == NULL);
32 locale_conv = initialize_utf8_conversion(locale_charset());
35 atexit(close_conversion_contexts);
43 char* convert_utf8_to_locale(const char* input, int *conv_fails)
46 open_conversion_contexts();
48 return convert_from_utf8(locale_conv, input, conv_fails);
51 char* convert_locale_to_utf8(const char* input)
54 open_conversion_contexts();
56 return convert_to_utf8(locale_conv, input);