Reputation: 369
I'm using Python 2.7.11 , I get a wrong value when getting decimal value of a character from extended ascii table
# -*- coding: utf-8 -*-
str="è"
print(ord(str[0])) #prints 232 decimal
but the value of this char is 138 decimal (http://www.asciitable.com/)
When i remove the coding utf-8 line i get this error SyntaxError: Non-ASCII character '\xe8'
Upvotes: 1
Views: 263
Reputation: 5516
The character è
referes in the unicode/utf-8 encoding to 0x00E8
which means 232
.
The character is contained in the extended ASCII see this
question for the extended ASCII and python.
Upvotes: 0
Reputation: 2852
UTF-8 is not extended asci. If you check the UTF-8 table here, you will see that 232 is indeed the correct ordinal.
Also, I recommend Joel on software's UTF-8 article
Upvotes: 3