newbie question about unicode

Carsten Haese carsten at uniqsys.com
Sat Jun 23 07:04:12 CEST 2007


On Sat, 23 Jun 2007 04:10:19 -0000, Genie T wrote
> Hi,
> 
> can anybody tell me whether these two expressions have the same
> meanings?
> 
> s = u'<unicode string here>'
> s1 = s.encode('utf-8')
> 
> AND
> 
> s1 = unicode(s,'utf-8')

Considering that one works and the other doesn't, no, they don't have the same
meaning.

The unicode() function decodes a given byte string into a unicode object, but
you're giving it a unicode object. What are you actually trying to achieve?

If you're just trying to get a handle on the topic, I recommend you read
http://www.amk.ca/python/howto/unicode

HTH,

--
Carsten Haese
http://informixdb.sourceforge.net




More information about the Python-list mailing list