Re: unicode question

2015-01-28 Thread Michael Torrie
On 01/28/2015 03:17 PM, Albert-Jan Roskam wrote: >> I do not know how complete the support is, but this is copied from 3.4.2, >> which uses tcl/tk 8.6. t = "الحركات" for c in t: print(c) # Prints rightmost char above first >> ا >> ل >> ح >> ر >> ك >> ا >> ت > > Wow, I never knew this w

Re: unicode question

2015-01-28 Thread Albert-Jan Roskam
On Wed, Jan 28, 2015 8:21 AM CET Terry Reedy wrote: >On 1/27/2015 12:17 AM, Rehab Habeeb wrote: >> Hi there python staff >> does python support arabic language for texts ? and what to do if it >> support it? >> i wrote hello in Arabic using codeskulptor and the powers

Re: unicode question

2015-01-27 Thread Terry Reedy
On 1/27/2015 12:17 AM, Rehab Habeeb wrote: Hi there python staff does python support arabic language for texts ? and what to do if it support it? i wrote hello in Arabic using codeskulptor and the powershell just for testing and the same error appeared( a sytanx error in unicode)!! I do not kno

Re: unicode question

2015-01-27 Thread random832
On Tue, Jan 27, 2015, at 12:25, Mark Lawrence wrote: > People might find this http://bugs.python.org/issue1602 and hence this > https://github.com/Drekin/win-unicode-console useful. The latter is > available on pypi. However, Arabic is one of those scripts that runs up against the real limitati

Re: unicode question

2015-01-27 Thread Mark Lawrence
On 27/01/2015 16:13, random...@fastmail.us wrote: On Tue, Jan 27, 2015, at 00:17, Rehab Habeeb wrote: Hi there python staff does python support arabic language for texts ? and what to do if it support it? i wrote hello in Arabic using codeskulptor and the powershell just for testing and the same

Re: unicode question

2015-01-27 Thread random832
On Tue, Jan 27, 2015, at 00:17, Rehab Habeeb wrote: > Hi there python staff > does python support arabic language for texts ? and what to do if it > support it? > i wrote hello in Arabic using codeskulptor and the powershell just for > testing and the same error appeared( a sytanx error in unicode)

Re: unicode question

2015-01-26 Thread Chris Angelico
On Tue, Jan 27, 2015 at 4:17 PM, Rehab Habeeb wrote: > Hi there python staff > does python support arabic language for texts ? and what to do if it support > it? > i wrote hello in Arabic using codeskulptor and the powershell just for > testing and the same error appeared( a sytanx error in unicod

Re: Unicode question

2006-07-28 Thread Martin v. Löwis
Ben Edwards (lists) wrote: > Firstly sys.setdefaultencoding('iso−8859−1') does not work, I have to do > sys.setdefaultencoding = 'iso−8859−1' That "works", but has no effect. You bind the variable sys.setdefaultencoding to some value, but that value is never used for anything (do sys.getdefaultenc

Re: Unicode question

2006-07-28 Thread Steve M
Ben Edwards (lists) wrote: > I am using python 2.4 on Ubuntu dapper, I am working through Dive into > Python. > > There are a couple of inconsictencies. > > Firstly sys.setdefaultencoding('iso-8859-1') does not work, I have to do > sys.setdefaultencoding = 'iso-8859-1' When you run a Python script

Re: Unicode question

2006-07-28 Thread Max Erickson
"Ben Edwards (lists)" <[EMAIL PROTECTED]> wrote: > I am using python 2.4 on Ubuntu dapper, I am working through Dive > into Python. ... > Any insight? > Ben Did you follow all the instructions, or did you try to call sys.setdefaultencoding interactively? See: http://diveintopython.org/xml_pro

Re: Unicode question : turn "José" into u"José"

2006-04-05 Thread Ben Finney
"Ian Sparks" <[EMAIL PROTECTED]> writes: > This is probably stupid and/or misguided but supposing I'm passed a > byte-string value that I want to be unicode, this is what I do. I'm > sure I'm missing something very important. Perhaps you need to read one of the good Python Unicode tutorials, such

Re: Unicode question : turn "José" into u"José"

2006-04-05 Thread Kent Johnson
ianaré wrote: > maybe a bit off topic, but how does one find the console's encoding > from within python? > In [1]: import sys In [3]: sys.stdout.encoding Out[3]: 'cp437' In [4]: sys.stdin.encoding Out[4]: 'cp437' Kent -- http://mail.python.org/mailman/listinfo/python-list

Re: Unicode question : turn "José" into u"José"

2006-04-05 Thread John Machin
The most important thing that you are missing is that you need to know the encoding used for the 8-bit-character string. Let's guess that it's Latin1. Then all you have to do is use the unicode() builtin function, or the string decode method. # >>> s = 'Jos\xe9' # >>> s # 'Jos\xe9' # >>> u = unico

Re: Unicode question : turn "José" into u"José"

2006-04-05 Thread ianaré
maybe a bit off topic, but how does one find the console's encoding from within python? -- http://mail.python.org/mailman/listinfo/python-list

Re: Unicode question : turn "José" into u"José"

2006-04-05 Thread aurora
First of all, if you run this on the console, find out your console's encoding. In my case it is English Windows XP. It uses 'cp437'. C:\>chcp Active code page: 437 Then >>> s = "José" >>> u = u"Jos\u00e9" # same thing in unicode escape >>> s.decode('cp437') == u # use encoding that

Re: unicode question

2006-03-01 Thread Walter Dörwald
Edward Loper wrote: > Walter Dörwald wrote: >> Edward Loper wrote: >> >>> [...] >>> Surely there's a better way than converting back and forth 3 times? Is >>> there a reason that the 'backslashreplace' error mode can't be used >>> with codecs.decode? >>> >>> >>> 'abc \xff\xe8 def'.decode('ascii

Re: unicode question

2006-02-27 Thread Edward Loper
Walter Dörwald wrote: > Edward Loper wrote: > >> [...] >> Surely there's a better way than converting back and forth 3 times? Is >> there a reason that the 'backslashreplace' error mode can't be used >> with codecs.decode? >> >> >>> 'abc \xff\xe8 def'.decode('ascii', 'backslashreplace') >> Trac

Re: unicode question

2006-02-27 Thread Walter Dörwald
Edward Loper wrote: > [...] > Surely there's a better way than converting back and forth 3 times? Is > there a reason that the 'backslashreplace' error mode can't be used with > codecs.decode? > > >>> 'abc \xff\xe8 def'.decode('ascii', 'backslashreplace') > Traceback (most recent call last): >

Re: unicode question

2006-02-25 Thread Kent Johnson
Edward Loper wrote: > I would like to convert an 8-bit string (i.e., a str) into unicode, > treating chars \x00-\x7f as ascii, and converting any chars \x80-xff > into a backslashed escape sequences. I.e., I want something like this: > > >>> decode_with_backslashreplace('abc \xff\xe8 def') > u'a

Re: unicode question

2006-02-25 Thread Tim Roberts
Edward Loper <[EMAIL PROTECTED]> wrote: >I would like to convert an 8-bit string (i.e., a str) into unicode, >treating chars \x00-\x7f as ascii, and converting any chars \x80-xff >into a backslashed escape sequences. I.e., I want something like this: > > >>> decode_with_backslashreplace('abc \xff

Re: Unicode Question

2006-01-09 Thread David Pratt
Hi Max. Many thanks for helping to realize where I was missing the point and making this clearer. Regards, David Max Erickson wrote: > The encoding argument to unicode() is used to specify the encoding of the > string that you want to translate into unicode. The interpreter stores > unicode as

Re: Unicode Question

2006-01-09 Thread David Pratt
Hi Erik. Thank you for your reply. The advice I has helped clarify this for me. Regards, David Erik Max Francis wrote: > David Pratt wrote: > > >>This is not working for me. Can someone explain why. Many thanks. > > > Because '\xbe' isn't UTF-8 for the character you want, '\xc2\xbe' is, as

Re: Unicode Question

2006-01-09 Thread David Pratt
Hi Martin. Many thanks for your reply. What I am reall after, the following accomplishes. > > If you are looking for "at the same time", perhaps this is also > interesting: > > py> unicode('\xbe', 'windows-1252').encode('utf-8') > '\xc2\xbe' > Your answer really helped quite a bit to clarify t

Re: Unicode Question

2006-01-09 Thread Max Erickson
The encoding argument to unicode() is used to specify the encoding of the string that you want to translate into unicode. The interpreter stores unicode as unicode, it isn't encoded... >>> unicode('\xbe','cp1252') u'\xbe' >>> unicode('\xbe','cp1252').encode('utf-8') '\xc2\xbe' >>> max -- ht

Re: Unicode Question

2006-01-09 Thread Martin v. Löwis
David Pratt wrote: > I want to prepare strings for db storage that come from normal Windows > machine (cp1252) so my understanding is to unicode and encode to utf-8 > and to store properly. That also depends on the database. The database must accept UTF-8-encoded strings, and must not modify them

Re: Unicode Question

2006-01-09 Thread Erik Max Francis
David Pratt wrote: > This is not working for me. Can someone explain why. Many thanks. Because '\xbe' isn't UTF-8 for the character you want, '\xc2\xbe' is, as you just showed yourself in the code snippet. -- Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.com/max/ San Jose, CA, US

Re: unicode question

2004-11-29 Thread Bengt Richter
On Tue, 23 Nov 2004 20:37:04 +0100, =?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?= <[EMAIL PROTECTED]> wrote: >Steve Holden wrote: >> Am I the only person who found it scary that Bengt could apparently >> casually drop on a polynomial the would decode to " Löwis"? Well, don't give me too much credit