471,337 Members | 1,068 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,337 software developers and data experts.

sys.setdefaultencoding

Can someone explain the rationale of making the default encoding a sitewide setting?

I could live with the the default being set on a per process basis, but it
baffles me why even that possibility is taken away as site.py removes
sys.setdefaultencoding.

Is there a way to allow the process to specify that unicode-->str should use
'utf8' rather than 'ascii' in all non-specific cases?
--
Robin Becker

Aug 28 '07 #1
1 3999
Is there a way to allow the process to specify that unicode-->str should
use 'utf8' rather than 'ascii' in all non-specific cases?
No. Things might break if you change the default encoding to anything
but ASCII, and more so if you do that "at runtime". For example,
dictionaries with Unicode keys may stop working, and the cached
byte-oriented version of a Unicode string may become incorrect.

In general, programs and libraries should not rely on the default
encoding for anything. Instead, they should convert explicitly,
either from an explicitly specified encoding, or one derived from
the context. Experience has shown that this is possible in nearly
every case (and in all cases if an appropriate refactoring is made).

Regards,
Martin
Aug 28 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by christof hoeke | last post: by
1 post views Thread by Paulo da Silva | last post: by
5 posts views Thread by Askari | last post: by
2 posts views Thread by Uwe Mayer | last post: by
2 posts views Thread by Ben Edwards (lists) | last post: by
6 posts views Thread by Franz Steinhaeusler | last post: by
11 posts views Thread by =?iso-8859-9?q?S=F6nmez_Kartal?= | last post: by
2 posts views Thread by smalltalk | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.