Movatterモバイル変換


[0]ホーム

URL:


[Python-Dev] Generalised String Coercion

"Martin v. Löwis"martin at v.loewis.de
Mon Aug 8 07:37:27 CEST 2005


Guido van Rossum wrote:>>If stdin, stdout and stderr go to a terminal, there already is a>>default encoding (actually, there always is a default encoding on>>these, as it falls back to the system encoding if its not a terminal,>>or if the terminal's encoding is not supported or cannot be determined).>>> So there is. Wow! I never kew this. How does it work? Can we use this> for writing to files to?On Unix, it uses nl_langinfo(CHARSET), which in turn looks at theenvironment variables.On Windows, it uses GetConsoleCP()/GetConsoleOutputCP().On Mac, I'm still searching for a way to determine the encoding ofTerminal.app.In IDLE, it uses locale.getpreferredencoding().So no, this cannot easily be used for file output. Most likely, peoplewould use locale.getpreferredencoding() for file output. For socketoutput, there should not be a standard way to encode Unicode.Regards,Martin


More information about the Python-Devmailing list

[8]ページ先頭

©2009-2025 Movatter.jp