If a command line program is unsure of stdout's encoding, what encoding should it output? If a command line program is unsure of stdout's encoding, what encoding should it output? shell shell

If a command line program is unsure of stdout's encoding, what encoding should it output?


I suggest you use the current locale.

Python2> import localePython2> locale.getpreferredencoding()'UTF-8'

The system knows what it should be, and the other side, if it also uses the current locale, will do the right thing.


if your application doesn't really deal with a whole lot of internationalisation, ascii should suffice. but if not, i'd say utf-8 or better still utf-16 should be the order of the day.