471,319 Members | 1,602 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

IDLE and non-ascii encoding workaround?

Hello everyone,

there have already been a couple of threads about IDLE's sometimes
annoying disability to use special characters (in my case I would like
to use for example german umlauts like "ä" etc.).
I have made a workaround that *seems* to work, so I can at least store
files in the editor that use such characters ( on the python shell I
still get:

UnicodeError: ASCII encoding error: ordinal not in range(128)

but that does not matter much to me).
However I don't know very much about encoding issues, so maybe someone
can tell me if there might be problems that I don't see at the moment.
Here's what I did:

I changed one line in the writefile function in IOBinding.py into a
try-except statement. My function now looks like this:

def writefile(self, filename):
#chars = str(self.text.get("1.0", "end-1c"))#original line
#workaround to fix the "umlaut" problem:
chars = str(self.text.get("1.0", "end-1c"))
c = self.text.get("1.0", "end-1c")
chars = ''
for i in c:
j = ord(i)
k = chr(j)
chars = chars + k
chars = str(chars)
#end of workaround
f = open(filename, "w")
## print "saved to", `filename`
return 1
except IOError, msg:
tkMessageBox.showerror("I/O Error", str(msg),
return 0

This may take a few seconds if you want to save a large file, but at
least it is better as if it wasn't possible at all.

Any hints on this would be very appreciated.
Thanks in anticipation.

Jul 18 '05 #1
1 2444
kl*******@web.de (klappnase) writes:
Any hints on this would be very appreciated.

I recommend to use the IDLE that comes with Python 2.3.

Jul 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

19 posts views Thread by Frank Rizzo | last post: by
14 posts views Thread by John Coleman | last post: by
reply views Thread by Michael Boldin via alt email | last post: by
3 posts views Thread by Dominique | last post: by
1 post views Thread by George2 | last post: by
reply views Thread by Terry Reedy | last post: by
reply views Thread by rosydwin | 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.