kh@lara:~/tmp $ python
Python 3.9.2 (default, Mar 12 2021, 04:06:34)
[GCC 10.2.1 20210110] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> str = 'äöü'
>>> len(str)
3
>>> ord(str[0])
228
>>> ord(str[1])
246
>>> ord(str[2])
252
>>> ord(str[3])
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
IndexError: string index out of range
>>> f = open ('uml.txt', 'w')
>>> f.write(str)
3
>>> f.close()
>>>
kh@lara:~/tmp $ hexdump uml.txt
0000000 a4c3 b6c3 bcc3
0000006
Can somebody explain this? 228, 246, 252 is 'äöü' in iso-8859-1.
doc.python.org: ord(c) Given a string representing one Unicode character, return an integer representing the Unicode code point of that character. For example, ord('a') returns the integer 97 and ord('€') (Euro sign) returns 8364. This is the inverse of chr().