しげろ 2007年12月19日 (水) 08:53 (JST) mod_python で日本語ファイル名を取り扱おうとして UnicodeEncodeError とか UnicodeDecodeError がでた場合の対処方法。 以下の話は debian etch での話です。 Python には file system encoding というのがある。 sys.getfilesystemencoding() でそれがわかる。 この値は、 Python が立ち上がったときに決められて、実行時には変更不可能みたい。 この file system encoding は環境変数 LANG によって変えることができる。 LANG=C の場合 $ LANG=C python -i >>> import sys >>> sys.getfilesystemencoding() 'ANSI_X3.4-1