Re: wxPython and Croatian characters

2009-02-17 Thread vedrandekovic
On 17 velj, 00:09, alejandro aleksanda...@brisiovonet.hr wrote:
 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
--
http://mail.python.org/mailman/listinfo/python-list


Re: wxPython and Croatian characters

2009-02-17 Thread Mike Driscoll
On Feb 17, 11:02 am, vedrandeko...@gmail.com wrote:
 On 17 velj, 00:09, alejandro aleksanda...@brisiovonet.hr wrote:

  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

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
--
http://mail.python.org/mailman/listinfo/python-list


Re: wxPython and Croatian characters

2009-02-16 Thread Diez B. Roggisch

vedrandeko...@gmail.com schrieb:

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

umö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
--
http://mail.python.org/mailman/listinfo/python-list


Re: wxPython and Croatian characters

2009-02-16 Thread Jason Scheirer
On Feb 16, 10:58 am, vedrandeko...@gmail.com wrote:
 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.
--
http://mail.python.org/mailman/listinfo/python-list


Re: wxPython and Croatian characters

2009-02-16 Thread J. Cliff Dyer
On Mon, 2009-02-16 at 20:06 +0100, Diez B. Roggisch wrote:
 vedrandeko...@gmail.com schrieb:
  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.
 

No.  The coding declaration does nothing to unicode literals.  It only
affects how the python's source code parser reads the the source code.
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.  If it's encoded in UTF-16,
however, it will choke right away, as it will immediately come across a
\x00 byte, which is treated as the ascii NULL character, which is not
legal in python source code.

But print will still try to encode all unicode objects to the encoding
of your terminal, and any file writing operations will try to decode as
ASCII, unless explicitly told otherwise.  Same as without the -*- coding
-*- declaration. 

For the OP:  

When dealing with potentially non-ascii text, always use unicode objects
instead of strings, and explicitly encode them to the encoding you want
on output, unless your printing facility (here wx.StaticText) handles
that for you.  I also don't know how wxpython works in this regard.  

So:

s = uMatični broj # instead of Matični broj
text = wx.StaticText(self, -1, s,(0,100))
# or if that doesn't work try this:
#text = wx.StaticText(self, -1, s.encode('utf-8'), (0,100))

Cheers,
Cliff


--
http://mail.python.org/mailman/listinfo/python-list


Re: wxPython and Croatian characters

2009-02-16 Thread Martin v. Löwis
 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.

 
 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
--
http://mail.python.org/mailman/listinfo/python-list


Re: wxPython and Croatian characters

2009-02-16 Thread 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 


--
http://mail.python.org/mailman/listinfo/python-list