encoding

I know it got nothing to do with wx but you guys have been so helpful so I hope you will help me anyway

if I want to print utf-8 string with python i should write

print u"hello word:"

now what happen if I wont to print a variable this way?

thank you!

Hello,

I know it got nothing to do with wx but you guys have been so helpful so I hope you will help me anyway

if I want to print utf-8 string with python i should write

print u"hello word:"

now what happen if I wont to print a variable this way?

Not completely clear on what you are asking but, did you try printing it and seeing what happens?

If you want to use utf-8 strings in your python source files you need to put an encoding statement in one of the top two lines of the file.

i.e) # -*- coding: utf-8 -*-

see: PEP 263 – Defining Python Source Code Encodings | peps.python.org
also: Mailing Lists | Python.org

Cody

···

On Sep 1, 2008, at 4:52 PM, יהודה wrote:

thank you I already solved it

unicode( “hello”, “utf-8” )

you don’t understand the problem probably because you don’t use to write with non-english char

···

On Tue, Sep 2, 2008 at 12:13 AM, Cody Precord codyprecord@gmail.com wrote:

Hello,

On Sep 1, 2008, at 4:52 PM, יהודה wrote:

I know it got nothing to do with wx but you guys have been so helpful so I hope you will help me anyway

if I want to print utf-8 string with python i should write

print u"hello word:"

now what happen if I wont to print a variable this way?

Not completely clear on what you are asking but, did you try printing it and seeing what happens?

If you want to use utf-8 strings in your python source files you need to put an encoding statement in one of the top two lines of the file.

i.e) # -- coding: utf-8 --

see: http://www.python.org/dev/peps/pep-0263/

also: http://www.python.org/community/lists/

Cody


wxpython-users mailing list

wxpython-users@lists.wxwidgets.org

http://lists.wxwidgets.org/mailman/listinfo/wxpython-users


http://kaze.co.il
יש קצה חוט לרעיון שלך

Hello,

thank you I already solved it

unicode( “hello”, “utf-8” )

you don’t understand the problem probably because you don’t use to write with non-english char

Actually I use and work with non roman alphabet characters all the time. I am also pretty sure you don’t know anything about me so I would appreciate it if you didn’t pretend you did ;). I was confused by what you meant by ‘print’ it can have many meanings (console, printer, file, display in ui, ect…).

The above code will take the raw string ‘hello’ and decode it to unicode with the utf-8 codec returning a unicode object, which will of course only work if the string you pass in can be decoded with utf-8. If you want an actual utf-8 string for output to a file or console you need to encode it from unicode to a utf-8 encoded string (u’'.encode(‘utf-8’)) otherwise on output the default encoding on your system will be used to convert from unicode to a string.

Anyway this is off topic you may find more information on the python mailing lists.

···

On Sep 1, 2008, at 6:02 PM, יהודה wrote:

On Tue, Sep 2, 2008 at 12:13 AM, Cody Precord codyprecord@gmail.com wrote:

Hello,

On Sep 1, 2008, at 4:52 PM, יהודה wrote:

I know it got nothing to do with wx but you guys have been so helpful so I hope you will help me anyway

if I want to print utf-8 string with python i should write

print u"hello word:"

now what happen if I wont to print a variable this way?

Not completely clear on what you are asking but, did you try printing it and seeing what happens?

If you want to use utf-8 strings in your python source files you need to put an encoding statement in one of the top two lines of the file.

i.e) # -- coding: utf-8 --

see: http://www.python.org/dev/peps/pep-0263/
also: http://www.python.org/community/lists/

Cody


wxpython-users mailing list
wxpython-users@lists.wxwidgets.org
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users


http://kaze.co.il
יש קצה חוט לרעיון שלך


wxpython-users mailing list
wxpython-users@lists.wxwidgets.org
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users