Help with Unicode? in Tkinter?

Maan Hamze mmhamze at pleiades.net
Sun Sep 2 01:12:38 EDT 2001


Ignacio
Do you know of any links on Unicode and Python.  I can not find any.
Maan

"Ignacio Vazquez-Abrams" <ignacio at openservices.net> wrote in message
news:mailman.999404342.13043.python-list at python.org...
On Sat, 1 Sep 2001, Sheila King wrote:

> When I try, I get things like this:
> Python 2.1.1 (#20, Jul 20 2001, 01:19:29) [MSC 32 bit (Intel)] on win32
> Type "copyright", "credits" or "license" for more information.
> IDLE 0.8 -- press F1 for help
> >>> print u'\xe7'
> Traceback (most recent call last):
>   File "<pyshell#0>", line 1, in ?
>     print u'\xe7'
> UnicodeError: ASCII encoding error: ordinal not in range(128)
> >>> ord(u'\xe7')
> 231
> >>> print unichr(231)
> Traceback (most recent call last):
>   File "<pyshell#2>", line 1, in ?
>     print unichr(231)
> UnicodeError: ASCII encoding error: ordinal not in range(128)
> >>>
>
> The ASCII encoding error: ordinal not in range(128) tells me that
> Tkinter is configured to only accept values in that range (the typical
> 7-bit ASCII code). I need to extend it to the latin-1 charset.

I think that the problem is that you're using unicode strings instead of
just
strings. Here's what I got under Idle (Python 1.5.2 though):

---
>>> print string.join(map(chr, range(160, 256)), '')
¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëì
íîïðñòóôõö÷øùúûüýþÿ
>>>
---

Try using just chr() instead of unichr().

--
Ignacio Vazquez-Abrams  <ignacio at openservices.net>







More information about the Python-list mailing list