|
From: Ethan M. <eam...@gm...> - 2011-11-04 23:34:40
|
2011/11/4 Bastian Märkisch <bma...@we...>:
> For the currently active locale you could also simply use wcrtomb() to
> convert.
If Solaris is reporting "PCK" instead of "Shift-JIS" in LC_CTYPE then
I would guess that wcrtomb and iconv either both fail or both work..
One would hope it would accept its own name convention!
I will try Shige's suggestion to use nl_langinfo().
Ethan
>
> Bastian
>
> Am 04.11.2011 08:54, schrieb Shigeharu TAKENO:
>>
>> shige 11/04 2011
>> ----------------
>>
>> Ethan A Merritt<sf...@us...> wrote:
>> | I have revised the new code to use iconv() if it is available.
>> | I tested under linux by setting the locale to ja_JP.EUC-JP,
>> | which causes it to emit the character sequence \241 \353 (octal)
>> | which is 0xA1EB (hexidecimal). But I don't have any EUC-JP fonts
>> | installed, so I cannot confirm if this is correct.
>>
>> The code 0xA1EB is correct for EUC-JP.
>>
>> Well, I think the idea
>>
>> + if (locale) {
>> + /* This should work even if gnuplot doesn't understand the
>> encoding */
>> + char *encoding = strchr(locale, '.');
>> + if (encoding) {
>> + encoding++; /* Step past the dot in, e.g., ja_JP.EUC-JP */
>>
>> of src/set.c is not so good, since substrings of locale name
>> after '.' may not proper name of the character encoding. For
>> example, in Solaris 9,
>>
>> EUC-JP enconding locale name = "ja", "ja_JP.EUC", "ja_JP.eucJP"
>> Shift_JIS encoding locale name = "ja_JP.PCK"
>> UTF-8 encoding locale name = "ja_JP.UTF-8"
>>
>> To obtain encoding codeset name of current locale, there seems to
>> be two methods:
>>
>> 1) Use nl_langinfo(CODESET) (#include<langinfo.h>)
>> 2) Use locale_charset() (#include<localcharset.h>) in libcharset,
>> which is included in GNU libiconv.
>>
>> cf. http://www.haible.de/bruno/packages-libcharset.html
>>
>> On Solaris 9, nl_langinfo(CODESET) of system library returns:
>>
>> locale = ja, ja_JP.eucJP => "eucJP"
>> locale = ja_JP.PCK => "PCK"
>>
>> and locale_charset() of GNU libcharset returns:
>>
>> locale = ja, ja_JP.eucJP => "EUC-JP"
>> locale = ja_JP.PCK => "SHIFT_JIS"
>>
>> I think that names returned by locale_charset() may be better,
>> but libcharset may not be installed in default.
>>
>>
>> | If you build the new code, you can test it by saying
>> | set encoding locale
>> | show decimal
>>
>> Though it puts a incorrect string on "ja" locale, it works fine
>> on "ja_JP.eucJP" locale since iconv library admits "eucJP".
>>
>> +========================================================+
>> Shigeharu TAKENO NIigata Institute of Technology
>> kashiwazaki,Niigata 945-1195 JAPAN
>> sh...@ie... TEL(&FAX): +81-257-22-8161
>> +========================================================+
>
>
|