[Tutor] Tutor Digest, Vol 54, Issue 64
lie.1296 at gmail.com
Mon Aug 18 12:15:31 CEST 2008
> Message: 1
> Date: Sun, 17 Aug 2008 11:33:28 +0200
> From: "Robert Johansson" <robert.johansson at math.umu.se>
> Subject: [Tutor] unsupported characters
> To: <Tutor at python.org>
> Message-ID: <000001c9004c$516e2fe0$f44a8fa0$@johansson at math.umu.se>
> Content-Type: text/plain; charset="iso-8859-1"
> Hi, I have problems using characters from the Swedish language. I
> tried the
> following in IDLE under MacOS X leopard (running Python 2.5.1) :
> Displaying error message: ?unsupported characters in input?.
This is because Python 2, by default, assumed ASCII encoding for its
source codes (Python 3, by default, assumed utf-8, I think). You can
change the default encoding by adding this "magic comment":
# coding=<encoding name>
# -*- coding: <encoding name> -*-
# vim: set fileencoding=<encoding name> :
to the first or second line of your source code (usually the <encoding
name> would be utf-8, but it can be any encoding supported by python).
The encoding declaration may be in the first or second line to allow its
usage together with pound-bang comment.
> Running Python from a terminal I can?t even type the character, all
> happens is that I get a little ?boing? from my machine.I tried to set
> various things like LC_CTYPE with the locale module but that doesn?t
> I don?t really know what that module does but If I try
> locale.getlocale(), I
> get: (?sv_SE?,?ISO8859-1?). Anyone who knows how to fix this? I would
> very grateful.
> -------------- next part --------------
> An HTML attachment was scrubbed...
More information about the Tutor