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
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
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
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
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
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