[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Testing for UTF-8 tty mode
To get this slightly more ontopic, can people please use code similar to
this for extracting the charset from LC_CTYPE, which is better than
cracking it open yourself...
#include <langinfo.h>
#ifdef _NL_CTYPE_CODESET_NAME
charset = nl_langinfo (_NL_CTYPE_CODESET_NAME);
#elif CODESET
charset = nl_langinfo(CODESET);
#endif
This has the advantage that if I defined, e.g. "en_GB" to be an alias for
"en_GB.UTF-8", it would detect UTF-8ness then.
Note that this will require setlocale(LC_ALL, ""); or similar to be done
previously.
--
Robert
The ASCII Consortium : dragging character encoding kicking and screaming
into the 20th century! <http://www.ecs.soton.ac.uk/~rwb197/ascii/>
-
Linux-UTF8: i18n of Linux on all levels
Archive: http://mail.nl.linux.org/lists/