Vinay Sajip wrote:
Thanks to
http://bugs.python.org/issue7077

I've noticed that the socket-based logging handlers - SocketHandler,
DatagramHandler and SysLogHandler - aren't Unicode-aware and can break in the
presence of Unicode messages. I'd like to fix this by giving these handlers an
optional (encoding=None) parameter in their __init__, and then using this to
encode on output. If no encoding is specified, is it best to use
locale.getpreferredencoding(), sys.getdefaultencoding(),
sys.getfilesystemencoding(), 'utf-8' or something else? On my system:

sys.getdefaultencoding()
'ascii'
sys.getfilesystemencoding()
'mbcs'
locale.getpreferredencoding()
'cp1252'

which suggests to me that the locale.getpreferredencoding() should be the
default. However, as I'm not a Unicode maven, any suggestions would be welcome.

Well, encodings can vary from machine to machine, and if the encoding
doesn't cover all the Unicode codepoints then you could get an encoding
exception. For these reasons I'd vote for UTF-8.
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to