wxPython and Croatian characters

V

vedrandekovic

Hello,

I have problem with configuring my wxPython script to work with
Croatian characters like: ð,¹,¾,è,æ.
Here is my simple script without wxPython (this script works):

# -*- coding: utf-8 -*-
s = "hello normal string ð¹¾æè"
print s

...here is my snippet with wxPython:

text = wx.StaticText(self, -1,"Matièni broj",(0,100)) # in this
example,we have character "è"

....when I run this text, it looks something like: "Mati",some weird
characters ,and "ni"

Regards,
John
 
D

Diez B. Roggisch

Hello,

I have problem with configuring my wxPython script to work with
Croatian characters like: ð,¹,¾,è,æ.
Here is my simple script without wxPython (this script works):

# -*- coding: utf-8 -*-
s = "hello normal string ð¹¾æè"
print s

..here is my snippet with wxPython:

text = wx.StaticText(self, -1,"Matièni broj",(0,100)) # in this
example,we have character "è"

...when I run this text, it looks something like: "Mati",some weird
characters ,and "ni"

Unless you are using python 3.0 (which I doubt, afaik no wx available),
your above coding declaration is useless for the shown piece of code, as
it only applies to unicode literals, which are written with a preceding u.

So

u"mönsch ist doch nicht so schwer"


gives you an unicode literal, that wx might work with (don't know wx)

And of course you need to make sure your editor produces utf-8 as
output, otherwise the exercise is futile as well.

Diez
 
J

Jason Scheirer

Hello,

I have problem with configuring my wxPython script to work with
Croatian characters like:  ð,¹,¾,è,æ.
Here is my simple script without wxPython (this script works):

      # -*- coding: utf-8 -*-
      s = "hello normal string ð¹¾æè"
      print s

..here is my snippet with wxPython:

    text = wx.StaticText(self, -1,"Matièni broj",(0,100)) # in this
example,we have character "è"

...when I run this text, it looks something like:  "Mati",some weird
characters ,and "ni"

Regards,
John

You may be using an ANSI build of wxWidgets instead of a unicode one.
Make sure to enable Unicode when you run ./configure, or if in
Windows, uninstall and download the win32-unicode version of the
wxPython you want.
 
M

Martin v. Löwis

Unless you are using python 3.0 (which I doubt, afaik no wx available),
No. The coding declaration does nothing to unicode literals. It only
affects how the python's source code parser reads the the source code.

And, as such, it *only* affects Unicode literals, really nothing else
(except for error checking).

In 2.x, non-ASCII characters can occur only in these places:
- comments. no effect on semantics of script
- string literals. run-time representation is equal to on-disk
representation, so no effect.
- unicode literals. run-time representation is 2-byte or 4-byte UCS,
so parser needs to decode on-disk representation to in-memory
representation. This is the *only* place where the declared encoding
matters.
Without it, your source code will be parsed (or is it lexed?) by python
as an ascii document. So if your document is UTF-8, it will choke as
soon as it reaches a non ascii character.

So yes, it does an additional error check also. But the main reason for
the encoding declaration (besides sanity for text editors also) is
Unicode literals (in 3.x, also relevant for identifiers)

Regards,
Martin
 
A

alejandro

Provjeri da si nisi stavio ansii kada si instalirao wx.python.
Mozes probat ubacit iznad svega u fajlu komentar u kojem pise da je fajl u
UTF-8 i onda bi ti trebalo sljakat. Nadem sutra pa ti posaljem
 
V

vedrandekovic

Provjeri da si nisi stavio ansii kada si instalirao wx.python.
Mozes probat ubacit iznad svega u fajlu komentar u kojem pise da je fajl u
UTF-8 i onda bi ti trebalo sljakat. Nadem sutra pa ti posaljem

Pozdrav / Hello,

It works now, all post were very useful, but now i have same problem
with python MySQLdb. I want data that I got from
wxPython TextCtrl write to MySQL database, but I don't know how to
configure it.

Any examples?

Regards,
John
 
M

Mike Driscoll

Pozdrav / Hello,

It works now, all post were very useful, but now i have same problem
with python MySQLdb. I want data that I got from
wxPython TextCtrl write to MySQL database, but I don't know how to
configure it.

Any examples?

Regards,
John

You'll need to look at the python database connector's docs and/or
MySQL's docs to know how to do that. It would help to know what you
are using to connect to the database: pyodbc, adodb, sqlalchemy?

Most of those packages have their own mailing lists, but you're
welcome to post here too.

Mike
 

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,780
Messages
2,569,611
Members
45,265
Latest member
TodLarocca

Latest Threads

Top