472,975 Members | 1,788 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,975 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 4089
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: christof hoeke | last post by:
hi, i wrote a small application which extracts a javadoc similar documentation for xslt stylesheets using python, xslt and pyana. using non-ascii characters was a problem. so i set the...
3
by: F. GEIGER | last post by:
When I start a py2exe-ed application I get the error 'ascii' codec can't encode character u'\xe9' in position 10: ordinal not in range(128) This is how I run py2exe: setup.py py2exe -O1...
1
by: Paulo da Silva | last post by:
Hi. I am using unicode encode method to write some accented chars to files (%s). Do I need to use the method "encode" always? Isn't there a general way to declare the encoding for the whole...
5
by: Askari | last post by:
Where is the method : "sys.setdefaultencoding(name)"? Problem : I want change the default encoding because I want put french letter : ...etc in widget with no problem! When I use the method...
2
by: Uwe Mayer | last post by:
Hi, well, I wrote a nice python program which won't work if the default encoding has not been set from ascii to latin-1 or latin-15. However, the command sys.setappdefaultencoding is missing...
2
by: Ben Edwards (lists) | last post by:
I am using python 2.4 on Ubuntu dapper, I am working through Dive into Python. There are a couple of inconsictencies. Firstly sys.setdefaultencoding('iso−8859−1') does not work,I have to...
6
by: Franz Steinhaeusler | last post by:
Hello NG, a little longer question, I'm working on our project DrPython and try fix bugs in Linux, (on windows, it works very good now with latin-1 encoding). On Windows, it works good now,...
11
by: =?iso-8859-9?q?S=F6nmez_Kartal?= | last post by:
Hello, I've had an encoding issue and solved it by "sys.setdefaultencoding('utf-8')"... My first try wasn't successful since setdefaultencoding is not named when I imported sys module. After,...
2
by: smalltalk | last post by:
>>import sys Traceback (most recent call last): File "<interactive input>", line 1, in <module> AttributeError: 'module' object has no attribute 'setdefaultencoding' but i find the...
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.