On Tuesday 18 May 2004 5:43 pm, Tomohiro KUBOTA wrote:
> From: Wesley J Landaker <[EMAIL PROTECTED]>
> > Basically, you just:
> >
> > iconv_t ic = iconv_open("UTF-8","ISO-8859-1"); // for example
> > // use iconv(ic,...) to do your conversions
> > iconv_close(ic);
>
> Please use nl_langinfo(CODESET) for encoding name of char* string,
> because the encoding of char* string depends on locale.
> On most GNU-based systems it is available. You have to call
> setlocale() in advance.
>
> iconv_t ic = iconv_open("UTF-8",nl_langinfo(CODESET));
>
> instead of
>
> iconv_t ic = iconv_open("UTF-8","ISO-8859-1");You are absolutely correct; it's a bad idea to assume the local encoding--I overzealously simplified in my example. =) Naming the encodings specificially is only useful if you are transcoding between two known encodings. -- Wesley J. Landaker <[EMAIL PROTECTED]> OpenPGP FP: 4135 2A3B 4726 ACC5 9094 0097 F0A9 8A4C 4CD6 E3D2
pgpsMtAr4XFLF.pgp
Description: signature
