Movatterモバイル変換


[0]ホーム

URL:


[Python-Dev] Add a new "locale" codec?

Stephen J. Turnbullstephen at xemacs.org
Thu Feb 9 15:59:48 CET 2012


Victor Stinner writes: > There is the same problem [that encode-decode with the 'locale' > codec doesn't roundtrip reliably] with the filesystem encoding > (sys.getfilesystemencoding()),-1 on a query to the OS that pretends to be a constant.You see, it's not the same problem.  The difference is that 'locale'is a constant and should correspond to a constant encoding, while'sys.getfilesystemcoding()' is a library function that queries thesystem, and it's obvious from the syntax that this is expected tochange in various circumstances, so if you want roundtripping you needto save the result.Having a nondeterministic "locale" codec is just begging application(and maybe a few middleware) programmers to use it everywhere theydon't feel like thinking about I18N.  Experience shows that that iseverywhere!If this is needed, it should be spelled "os.getlocaleencoding()" (or"sys.getlocaleencoding()"?)  Possibly there should be correspondinggetlocalelanguage(), getlocaleregion(), and getlocalemodifier()functions, and they should take an optional string argument whoseappropriate component is returned.Or maybe there should be a "parselocalestring()" function that returnsa named tuple.Or maybe this three-line function doesn't need to be a builtin?


More information about the Python-Devmailing list

[8]ページ先頭

©2009-2025 Movatter.jp