I've created a dictionnary with Python but I've got problems with extended Ascii codes.
The loop that creats the dictionnary is : (ascii number 128 to 164 : é,à etc)
#extented ascii codes
i = 128
while i <= 165 :
dictionnary[chr(i)] = 'extended ascii'
i = i + 1
But when I try to use dictionnary :
>>> dictionnary['è']
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
KeyError: '\xc3\xa8'
I've got # -- coding: utf-8 -- in the header of the python script. I've tried encode,decode etc but the result is always bad.
To understand what happens, I've tried :
>>> ord('é')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: ord() expected a character, but string of length 2 found
and
>>> ord(u'é')
233
I'am confused with ord(u'é') because 'é' is number 130 in extended ascii table and not 233.
I understand that extended ascii codes contains "two characters" but I don't understand how to solve the problem with dictionnary ?
Thanks in advance ! :-)