Swedish characters in Python strings
Fredrik Lundh
fredrik at pythonware.com
Sun Oct 13 07:22:36 EDT 2002
Urban Anjar wrote:
> That is perfectly OK, but...
>
> >>> S = 'åäö'
> >>> print S
> åäö
> >>> print len(S)
> 6
on all machines I have access to, I get:
>>> S = "åäö"
>>> print S
åäö
>>> print len(S)
3
check the locale settings; to minimize the pain, make sure you use
an 8-bit encoding (e.g ISO-8859-1) and not a designed-for-internal-
use-only variable-width encoding like UTF-8.
with UTF-8, your operating system is messing things up before Python
gets a chance to look at the characters (most likely, Python gets 6
characters from the keyboard, and sends 6 characters to the console).
if you cannot get RedHat to behave intelligentely, use a decent editor
instead.
(avoiding RedHat 8.0 might also help. based on the kind of bugs I've
experienced this far, 8.0 might qualify as the worst unix-like operating
system ever released...)
</F>
More information about the Python-list
mailing list