Re: utf8 silly question

2005-06-21 Thread John Machin
Jeff Epler wrote: > If you want to work with unicode, then write > us = u"\N{COPYRIGHT SIGN} some text" You can avoid almost all the wear and tear on your shift keys: >>> u"\N{copyright sign}" u'\xa9' ... you are stuck with \N for reasons that should be obvious :-) Cheers, John -- htt

Re: utf8 silly question

2005-06-21 Thread Konstantin Veretennicov
On 6/21/05, Jeff Epler <[EMAIL PROTECTED]> wrote: > If you want to work with unicode, then write > us = u"\N{COPYRIGHT SIGN} some text" ...and you can get unicode character names like that from unicodedata module: >>> import unicodedata >>> unicodedata.name(unichr(169)) 'COPYRIGHT SIGN' See a

Re: utf8 silly question

2005-06-21 Thread Jeff Epler
If you want to work with unicode, then write us = u"\N{COPYRIGHT SIGN} some text" You can also write this as us = unichr(169) + u" some text" When you have a Unicode string, you can convert it to a particular encoding stored in a byte string with bs = us.encode("utf-8") It's gen

Re: utf8 silly question

2005-06-21 Thread Steven Bethard
Grig Gheorghiu wrote: import codecs print codecs.encode(c, 'utf-8') > > © some text Or simply: py> print c.encode('utf-8') © some text -- http://mail.python.org/mailman/listinfo/python-list

Re: utf8 silly question

2005-06-21 Thread Qiangning Hong
Catalin Constantin wrote: > i have the following code: > > c=chr(169)+" some text" > > how can i utf8 encode the variable above ? > something like in php utf8_encode($var);?! > > chr(169) is the © (c) sign ! > > 10x for your help ! > > p.s.: i tryed using codecs, etc but always get an error me

Re: utf8 silly question

2005-06-21 Thread Grig Gheorghiu
Salut, Catalin You can first convert your c string to unicode, and in the process specify an encoding that understands non-ASCII characters (if you don't specify an encoding, it will try to use your default, which is most likely ASCII, and you'll get the error you mentioned.). In the following exa

utf8 silly question

2005-06-21 Thread Catalin Constantin
i have the following code: c=chr(169)+" some text" how can i utf8 encode the variable above ? something like in php utf8_encode($var);?! chr(169) is the © (c) sign ! 10x for your help ! p.s.: i tryed using codecs, etc but always get an error message like: 'ascii' codec can't decode byte 0xa9 i