Index
2012-04-18 09:28 – Zdravko Subakov : [dabo-users] Unicode Encode Error
2012-04-18 09:58 – Ed Leafe : Re: [dabo-users] Unicode Encode Error
2012-04-19 00:02 – Zdravko Subakov : Re: [dabo-users] Unicode Encode Error
2012-04-19 01:02 – Zdravko Subakov : Re: [dabo-users] Unicode Encode Error
2012-04-20 13:33 – Zdravko Subakov : Re: [dabo-users] Unicode Encode Error
2012-04-20 13:39 – Paul McNett : Re: [dabo-users] Unicode Encode Error
2012-04-20 13:55 – Zdravko Subakov : Re: [dabo-users] Unicode Encode Error
2012-04-20 15:51 – Ed Leafe : Re: [dabo-users] Unicode Encode Error
2012-04-20 16:07 – Zdravko Subakov : Re: [dabo-users] Unicode Encode Error
2012-04-23 15:21 – Ed Leafe : Re: [dabo-users] Unicode Encode Error
Back to top
[dabo-users] Unicode Encode Error

Author: Zdravko Subakov

Posted: 2012-04-18 09:28:27   Link

Hi,

I am strugling with unicode strings.

It is the modified version of PyCon Hello World simple form, but as soon as I introduced unicode characters in strings Dabo (Python) always get stuck and in cmd window I can see Unicode Encode Error: 'ascii' codec can't encode chracter u'\u017d' in position 154: ordinal not in range(128)

here is the code

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

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

import dabo

dabo.ui.loadUI("wx")

class HelloPyConForm(dabo.ui.dForm):

def afterInit(self):

tekst = u"Pozdrav Ž".encode("utf-8")

self.Caption = u"Hello PyCon"

self.lblHello = dabo.ui.dLabel(self,

Caption=tekst, FontSize=24,

ForeColor="blue")

app = dabo.dApp()

app.MainFormClass = HelloPyConForm

app.start()

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

Z.

--- StripMime Report -- processed MIME parts ---

multipart/alternative

text/plain (text body -- kept)

text/html

---

_______________________________________________

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/CE4774CBF7F843E189468B3BD1DB710A@Perajoe

©2012 Zdravko Subakov
Back to top
Re: [dabo-users] Unicode Encode Error

Author: Ed Leafe

Posted: 2012-04-18 09:58:14   Link

On Apr 18, 2012, at 9:28 AM, Zdravko Subakov wrote:

> I am strugling with unicode strings.

>

> It is the modified version of PyCon Hello World simple form, but as soon as I introduced unicode characters in strings Dabo (Python) always get stuck and in cmd window I can see Unicode Encode Error: 'ascii' codec can't encode chracter u'\u017d' in position 154: ordinal not in range(128)

> here is the code

Your code ran without error on my system. In fact, if I remove the encode call and just use:

tekst = "Pozdrav Ž"

...it works fine, too. Maybe you have the ANSI version of wxPython installed? Can you run any Dabo app, and select the Help/About menu, copy the system information, and then paste it into your reply?

-- Ed Leafe

_______________________________________________

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/11C78259-D4AB-4C98-A326-D76BD84FE827@leafe.com

©2012 Ed Leafe
Back to top
Re: [dabo-users] Unicode Encode Error

Author: Zdravko Subakov

Posted: 2012-04-19 00:02:37   Link

That Is strange because I was also able to use unicode strings using IDLE

editor with just encoding comment at the top of program, but here none of

the tried examles worked.

The version of wxPython is Unicode, as is stated in Windows instalation

tutorial on your web site.

I used editor.py while coding and here is info from Help/about menu:

Platform: Win

Python Version: 2.7.1 on win32

Dabo Version: Version 0.9.4; Revision ~6879

UI Version: 2.8.12.1 on wxMSW

Z.

----- Original Message -----

From: "Ed Leafe" <ed@leafe.com>

To: "Dabo Users list" <dabo-users@leafe.com>

Sent: Wednesday, April 18, 2012 4:58 PM

Subject: Re: [dabo-users] Unicode Encode Error

Your code ran without error on my system. In fact, if I remove the encode

call and just use:

tekst = "Pozdrav Ž"

...it works fine, too. Maybe you have the ANSI version of wxPython

installed? Can you run any Dabo app, and select the Help/About menu, copy

the system information, and then paste it into your reply?

-- Ed Leafe

_______________________________________________

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/DED4358924C742B8905E97B61F53A948@Perajoe

©2012 Zdravko Subakov
Back to top
Re: [dabo-users] Unicode Encode Error

Author: Zdravko Subakov

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

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
Back to top
Re: [dabo-users] Unicode Encode Error

Author: Zdravko Subakov

Posted: 2012-04-20 13:33:17   Link

Ok, I thought someone might be doing something about my unicode problem but

there is not a single answer on my pretty long previous post. I even posted

the entire error.

This might not be a problem for english speaking users of Dabo, but my

initial desision to try Python and Dabo is unicode support (and its price

tag - 0 ) which gives me tool to make application usable in any of

neighbouring countries.

Now I am stuck on the front door and I have been knocking ;)

Anyone?

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/FC523AC5C31C4878B97B67252EFBB844@Perajoe

©2012 Zdravko Subakov
Back to top
Re: [dabo-users] Unicode Encode Error

Author: Paul McNett

Posted: 2012-04-20 13:39:12   Link

On 4/20/12 11:33 AM, Zdravko Subakov wrote:

> Ok, I thought someone might be doing something about my unicode problem but

> there is not a single answer on my pretty long previous post. I even posted

> the entire error.

> This might not be a problem for english speaking users of Dabo, but my

> initial desision to try Python and Dabo is unicode support (and its price

> tag - 0 ) which gives me tool to make application usable in any of

> neighbouring countries.

> Now I am stuck on the front door and I have been knocking ;)

>

> Anyone?

Can you narrow down for us when/where this is happening? IOW, if you run

dabo/demo/DaboDemo.py, does that cause a unicode error?

Thanks

Paul

_______________________________________________

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/4F91AD50.8040004@ulmcnett.com

©2012 Paul McNett
Back to top
Re: [dabo-users] Unicode Encode Error

Author: Zdravko Subakov

Posted: 2012-04-20 13:55:05   Link

Thanks Paul for being so quick,

No, the dabodemo worked ok, I even lost some time with that Montana

solitaire. The problem started when I tried to modify the PyCon 2010 Hello

World application.

I copied a couple of lines and it worked.

Ok I thought, how does it look if I try the only 5 different letters(from

English Latin) in Serbian Latin SDCCZ. And as soon as I put it app was

stuck, the error appeared in command window, so the only way out was CTRL+C,

which terminated Python call for editor.py which I have been using to code

the Hello World program.

Z.

----- Original Message -----

From: "Paul McNett" <p@ulmcnett.com>

To: "Dabo Users list" <dabo-users@leafe.com>

Sent: Friday, April 20, 2012 8:39 PM

Subject: Re: [dabo-users] Unicode Encode Error

>

> Can you narrow down for us when/where this is happening? IOW, if you run

> dabo/demo/DaboDemo.py, does that cause a unicode error?

>

> Thanks

> Paul

>

>

> _______________________________________________

> 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/4F91AD50.8040004@ulmcnett.com

>

_______________________________________________

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/4D4BBF2E53BE4CD097B186F4ABC8E8B9@Perajoe

©2012 Zdravko Subakov
Back to top
Re: [dabo-users] Unicode Encode Error

Author: Ed Leafe

Posted: 2012-04-20 15:51:37   Link

On Apr 20, 2012, at 3:19 PM, Zdravko Subakov wrote:

> "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 905, in onRunScript

> f.write(txt)

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

> position 1

> 53: ordinal not in range(128)

I think that the problem is that Dabo is defaulting to UTF8, while your system is configured for CP1250.

Try this (in addition to Paul's suggestion): create a file in your app directory named 'settings_override.py', and in it include a single line:

defaultEncoding = 'cp1250'

Let us know if that makes a difference.

-- Ed Leafe

_______________________________________________

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/904FCE2B-9FE4-4609-A5F9-0CDE96119704@leafe.com

©2012 Ed Leafe
Back to top
Re: [dabo-users] Unicode Encode Error

Author: Zdravko Subakov

Posted: 2012-04-20 16:07:39   Link

If by app dir you ment directory where the Hello World app reside I did

that, but the result is the same error.

Z.

----- Original Message -----

From: "Ed Leafe" <ed@leafe.com>

To: "Dabo Users list" <dabo-users@leafe.com>

Sent: Friday, April 20, 2012 10:51 PM

Subject: Re: [dabo-users] Unicode Encode Error

> On Apr 20, 2012, at 3:19 PM, Zdravko Subakov wrote:

>

>> "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 905, in onRunScript

>> f.write(txt)

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

>> position 1

>> 53: ordinal not in range(128)

>

> I think that the problem is that Dabo is defaulting to UTF8, while your

> system is configured for CP1250.

>

> Try this (in addition to Paul's suggestion): create a file in your app

> directory named 'settings_override.py', and in it include a single line:

>

> defaultEncoding = 'cp1250'

>

> Let us know if that makes a difference.

>

>

>

> -- Ed Leafe

>

>

>

> _______________________________________________

> 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/904FCE2B-9FE4-4609-A5F9-0CDE96119704@leafe.com

>

_______________________________________________

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/0237FF6337554C3AA70E56AF3DAF401B@Perajoe

©2012 Zdravko Subakov
Back to top
Re: [dabo-users] Unicode Encode Error

Author: Ed Leafe

Posted: 2012-04-23 15:21:34   Link

On Apr 20, 2012, at 1:33 PM, Zdravko Subakov wrote:

> Ok, I thought someone might be doing something about my unicode problem but

> there is not a single answer on my pretty long previous post. I even posted

> the entire error.

> This might not be a problem for english speaking users of Dabo, but my

> initial desision to try Python and Dabo is unicode support (and its price

> tag - 0 ) which gives me tool to make application usable in any of

> neighbouring countries.

> Now I am stuck on the front door and I have been knocking ;)

Sorry to have not responded promptly about this - I've been dealing with some minor but annoying health issues.

I've followed what you've been doing, and the problem is definitely with the Dabo Editor and its support of different encodings. If everything is ascii or utf8 it seems to work fine, but apparently you have been the first person to test it with other encodings. I'll try to see if I can figure out a cleaner way to deal with this, but in the meantime, I'd suggest using any other text editor - the Dabo Editor is not a critical part of the Dabo world.

-- Ed Leafe

_______________________________________________

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/C6EF2115-6476-4BCC-AB62-8AA3D43F7F24@leafe.com

©2012 Ed Leafe