On 2006-07-14 10:52:22, Diez B. Roggisch wrote: >>>> Will print take care of encoding translation according to the encoding >>>> used in the target console? >>> >>> Of course not. AFAIK there is no way figuring out which encoding the >>> target console supports. The best you can do is to offer an option >>> that allwos selection of the output encoding. >> >> You can use the LANG environment variable on many systems. On mine, >> it's set to en_GB.UTF-8, which causes a lot of software to >> automatically choose the right encoding. > > That might be a good heuristic - but on my Mac no LANG is set. So I > should paraphrase my statement to "There is no reliable and > cross-platform way figuring out which encoding the console uses".
Right... without being a cross-platform specialist, I figured that much :) I just thought that maybe the Python runtime had platform-specific implementations for retrieving the platform-specific information about the encoding used in the runtime environment (which is probably there on many platforms) -- similar to maybe the platform-specific implementations of file access, process and thread handling etc. Anyway, it seems that anything non-ASCII is a bit problematic and needs "manual" handling of the runtime environment encoding. Seems a bit odd, given the worldwide distribution of Python... I would have thought that such a rather basic task like printing an accented character on a console had been solved in a standard way, rather than relying on individual (wheel-reinventing) custom coding. Isn't that something that pretty much everybody (outside the USA, at least) needs? Thanks for sharing your thoughts, Gerhard -- http://mail.python.org/mailman/listinfo/python-list