Re: [dabo-users] Unicode Encode Error

Author: Zdravko Subakov

Posted: 2012-04-19 at 01:02:05

Ok, to find out where the problem is I switched again to IDLE and made very

simple program

# -*- coding: utf-8 -*-

tekst="ŠĐČĆŽ"

print tekst

it worked without problem.

Then I removed the comment at the top and IDLE showed me I/O warning window

with the following message:

Non-ASCII found, yet no encoding declared. Add a line like

# -*- coding: cp1250 -*-

to your file.

Choose OK to save this file as CP1250

Edit your general options to silence this warning

Ok/Edit my file

I anyway run it and it worked ok and showed correct letters.

IDLE apparently found out that my WinXP installation is set to use CP1250

(Serbian Latin), which is needed to enable VFP to show my characters (ŠĐČĆŽ)

correctly. Could this be problem? I will switch to english temporarily to

check this out, but I have to restart ....

Ok, after restart I used the same IDLE program I wrote (see above) and it

appeared incorect immidiately. this is how it looks now.

tekst="ŠDEAŽ"

print tekst

When run it worked and showed above characters, so I added another 2 lines

and the program looks now like this:

tekst="ŠDEAŽ"

tekst2="ŠĐČĆŽ"

print tekst

print tekst2

when tried to run it it promped to save it saying something like "Cannot

save as CP1250 anymore, saving as UTF-8", I confirmed and it showed both

strings as they appear. (no comment line with coding at the top)

Now I switched again to Dabo and tried the PyCon Hello world form again with

unicode strings in a couple of variations and it failed each and every time.

Here is the complete error from command prompt:

*****************************

Traceback (most recent call last):

File

"C:\Python27\lib\site-packages\dabo-0.9.4-py2.7.egg\dabo\ui\uiwx\dMenuIte

m.py", line 58, in __onWxHit

self.raiseEvent(dEvents.Hit, evt)

File

"C:\Python27\lib\site-packages\dabo-0.9.4-py2.7.egg\dabo\ui\uiwx\dPemMixi

n.py", line 1045, in raiseEvent

super(dPemMixin, self).raiseEvent(eventClass, nativeEvent, *args,

**kwargs)

File

"C:\Python27\lib\site-packages\dabo-0.9.4-py2.7.egg\dabo\lib\eventMixin.p

y", line 81, in raiseEvent

bindingFunction(event)

File "editor.py", line 903, in onRunScript

f.write(txt)

UnicodeEncodeError: 'ascii' codec can't encode character u'\u017d' in

position 1

54: ordinal not in range(128)

*******************************************

Hope it helps

Z.

_______________________________________________

Post Messages to: Dabo-users@leafe.com

Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users

Searchable Archives: http://leafe.com/archives/search/dabo-users

This message: http://leafe.com/archives/byMID/630AE4F590EA4BD3ACC696C84245AB18@Perajoe

©2012 Zdravko Subakov