Re: string to unicode

2011-08-16 Thread Tim Roberts
Artie Ziff wrote: > >if I am using the standard csv library to read contents of a csv file >which contains Unicode strings (short example: >'\xe8\x9f\x92\xe8\x9b\x87'), You need to be rather precise when talking about this. That's not a "Unicode string" in Python terms. It's an 8-bit string.

Re: string to unicode

2011-08-15 Thread Thomas 'PointedEars' Lahn
Chris Angelico wrote: > On Mon, Aug 15, 2011 at 4:20 PM, Artie Ziff wrote: >> if I am using the standard csv library to read contents of a csv file >> which contains Unicode strings (short example: >> '\xe8\x9f\x92\xe8\x9b\x87'), how do I use a python Unicode method such as >> decode or encode to

Re: string to unicode

2011-08-15 Thread Terry Reedy
On 8/15/2011 11:29 AM, Adam Tauno Williams wrote: On Mon, 2011-08-15 at 08:20 -0700, Artie Ziff wrote: if I am using the standard csv library to read contents of a csv file which contains Unicode strings (short example: '\xe8\x9f\x92\xe8\x9b\x87'), how do I use a python Unicode method such as de

Re: string to unicode

2011-08-15 Thread Adam Tauno Williams
On Mon, 2011-08-15 at 08:20 -0700, Artie Ziff wrote: > if I am using the standard csv library to read contents of a csv file > which contains Unicode strings (short example: > '\xe8\x9f\x92\xe8\x9b\x87'), how do I use a python Unicode method such > as decode or encode to transform this string ty

Re: string to unicode

2011-08-15 Thread Chris Angelico
On Mon, Aug 15, 2011 at 4:20 PM, Artie Ziff wrote: > if I am using the standard csv library to read contents of a csv file which > contains Unicode strings (short example: '\xe8\x9f\x92\xe8\x9b\x87'), how do > I use a python Unicode method such as decode or encode to transform this > string type i

string to unicode

2011-08-15 Thread Artie Ziff
if I am using the standard csv library to read contents of a csv file which contains Unicode strings (short example: '\xe8\x9f\x92\xe8\x9b\x87'), how do I use a python Unicode method such as decode or encode to transform this string type into a python unicode type? Must I know the encoding (byt

Re: String to unicode - duplicating by function the effect of u prefix

2009-06-19 Thread Vincent
On Jun 18, 3:23 pm, CiTro wrote: > Thank you, Peter. That solved my problem. the another way is, codecs.raw_unicode_escape_decode(stringOne) == stringTwo -- http://mail.python.org/mailman/listinfo/python-list

Re: String to unicode - duplicating by function the effect of u prefix

2009-06-19 Thread CiTro
Thank you, Peter. That solved my problem. -- http://mail.python.org/mailman/listinfo/python-list

Re: String to unicode - duplicating by function the effect of u prefix

2009-06-18 Thread Peter Otten
CiTro wrote: > I'm looking for a way to convert a string to it's unicode "brother". > > This means: > > stringOne = "\u0026" > stringTwo = u"\u0026" > > print unicode(stringOne) == stringTwo > > The result is false. What function should I use, to duplicate the > effect of the "u" prefix ? "\u

String to unicode - duplicating by function the effect of u prefix

2009-06-18 Thread CiTro
I'm looking for a way to convert a string to it's unicode "brother". This means: stringOne = "\u0026" stringTwo = u"\u0026" print unicode(stringOne) == stringTwo The result is false. What function should I use, to duplicate the effect of the "u" prefix ? -- http://mail.python.org/mailman/listi

RE:change string to unicode

2008-12-19 Thread jyoung79
Hi Steven and Peter, Thank you both very much for taking the time to answer my question. Your solutions work perfect! :-) Thanks again! Jay > How about > > >>> "\\u03b1".encode("ascii").decode("unicode-escape") > 'α' > > Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: change string to unicode

2008-12-19 Thread Peter Otten
jyoun...@kc.rr.com wrote: > If I have a string like so: > > a = '\\u03B1' > > and I want to make it display a Greek alpha character, is there a way to > convert it to unicode ('\u03B1')? I tried concatenating it like this: > > '\u' + '03B1' > > but that didn't work. I'm working in Python 3.0

Re: change string to unicode

2008-12-19 Thread Steven D'Aprano
On Fri, 19 Dec 2008 09:19:28 -0600, jyoung79 wrote: > If I have a string like so: > > a = '\\u03B1' > > and I want to make it display a Greek alpha character, is there a way to > convert it to unicode ('\u03B1')? I tried concatenating it like this: > > '\u' + '03B1' > > but that didn't work.

change string to unicode

2008-12-19 Thread jyoung79
If I have a string like so: a = '\\u03B1' and I want to make it display a Greek alpha character, is there a way to convert it to unicode ('\u03B1')? I tried concatenating it like this: '\u' + '03B1' but that didn't work. I'm working in Python 3.0 and was curious if this could be done. Than