Dave Smith writes:

> I'm in the process of writing a GTK+ (XFree86) program which needs
> to output information gathered from the user (in textboxes,
> typically) in UTF-8 format. My problem is, I can't seem to find a
> way to determine the current encoding of the text stored in the
> textbox so that I can do a conversion from encoding X to UTF8.

Hi,

Text strings passed along as 'char*' are generally in the encoding
which is specified by the LC_CTYPE facet of the current locale. To
retrieve it, you have to use
     setlocale(LC_CTYPE,"")
or
     setlocale(LC_ALL,"")
at the beginning of your program; then the function locale_charset()
defined in fileutils-4.0w/lib/{localcharset.c,config.charset} will
return the encoding as a string which you can just pass to iconv().

Bruno
-
Linux-UTF8:   i18n of Linux on all levels
Archive:      http://mail.nl.linux.org/lists/

Reply via email to