From: Tanaka Akira Date: 2008-01-24T13:04:34+09:00 Subject: [ruby-dev:33342] Re: Time#strftimeのエンコーディング In article <20080124034130.90EA5E060F@mail.bc9.jp>, Nobuyoshi Nakada writes: > まぁ、おそらくほとんどの場合は変換なしでも問題ないでしょう。ダメ > な場合は例外になるだけで。 いまのところ変換しないほうが自然なんじゃないかと思います。 > それよりも、 > LC_TIME=ja_JP.utf-8 LC_CTYPE=ja_JP.eucJP date +%a > などとするとUTF-8で出力されるわけですが、LC_TIMEをsetlocaleされ > ていたような場合、どういうエンコーディングで返されるか知る方法と > いうのはあるんでしたっけ。 POSIX の Locale の項によれば、そういう状況での挙動は undefined なんで、ないんじゃないかと思います。 | If different character sets are used by the locale categories, the results | achieved by an application utilizing these categories are undefined. Likewise, | if different codesets are used for the data being processed by interfaces whose | behavior is dependent on the current locale, or the codeset is different from | the codeset assumed when the locale was created, the result is also undefined. なので、環境変数をそういうふうに設定するんじゃない、というの が答になります。 なお、それが undefined なら LC_CTYPE だけ setlocale するのは いいのか、と疑うのが自然ですが、これは portable character set 部分 (だいたい ASCII 部分) が変化することは考えない、と いうように割り切っているといえます。もしかするとこれは デフォルトが ASCII だが EBCDIC locale が存在する環境があって LC_CTYPE だけを EBCDIC と設定してしまうことがあるとすれば、 問題になるのかもしれません。 -- [田中 哲][たなか あきら][Tanaka Akira]