sys.setdefaultencoding(name)

A

Askari

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 ".get" from a
widget (Text, Entry), the string returned is "fucked"...
In the Entry widget, the text is (with .insert) "été"
When I add a "é" at end (with my keyboard), th result is "étéé" OR a
raised error!

I find, on net, that I must use "sys.setdefaultencoding(name)".
I find find this methode in the doc (official) but the
"setdefaultencoding" name method is not in the sys module!?! (when I print
"dir(sys)"?! :-(

Askari
 
H

Harald Massa

Askari,
When I use the method ".get" from a widget (Text, Entry), the string
returned is "fucked"...

That must be a virus or something. Encoding issues normally provide garbled
strings, but not the word "fucked". Somebody is playing jokes with you.
I find, on net, that I must use "sys.setdefaultencoding(name)".

setdefaultencoding gets removed from sys after execution of site.py /
sitecustomize.py.

My solution is to grab site.py, dig up "default encoding" and change from
imperalistic ASCII to LATIN-1.

Some told me that avangarde persons also take UTF8.

Harald
 
R

Reinhold Birkenfeld

Harald said:
Askari,


That must be a virus or something. Encoding issues normally provide garbled
strings, but not the word "fucked". Somebody is playing jokes with you.

I doubt that the quotes in the OP indicate a literal string.

Reinhold
 
A

Askari

My solution is to grab site.py, dig up "default encoding" and change
from imperalistic ASCII to LATIN-1.

euh... I try (the line #2 and #3 in my ".py"):
"""
import site
site.encoding = "latin_1"
"""

but I have this error when I modify a widget (with keyboard) I have this
error :
"""
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc9 in position 0:
ordinal not in range(128)
"""

Why?
And, I do the good think? (site.encoding = "latin_1")


Askari
 
H

Harald Massa

Askari,
"""
import site
site.encoding = "latin_1"
"""

Why?
And, I do the good think? (site.encoding = "latin_1")

No, you do a the bad thing.

You have to EDIT the site.py within python\lib\site.py

open it within an editor, find "ASCII" and replace by latin1

site.encodiging="Latin_1" just adds an attribute NOBODY cares for to a
module in memory.

Harald
 
A

Askari

Askari,


No, you do a the bad thing.

You have to EDIT the site.py within python\lib\site.py

open it within an editor, find "ASCII" and replace by latin1

site.encodiging="Latin_1" just adds an attribute NOBODY cares for to a
module in memory.

Harald

It work! :)

Thanks!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top