> Message: 1 > Date: Sun, 17 Aug 2008 11:33:28 +0200 > From: "Robert Johansson" <[EMAIL PROTECTED]> > Subject: [Tutor] unsupported characters > To: <Tutor@python.org> > Message-ID: <[EMAIL PROTECTED]@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) : > > > > S=??? > > > > 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> or: # -*- coding: <encoding name> -*- or: # 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. read: http://www.python.org/dev/peps/pep-0263/ > > Running Python from a terminal I can?t even type the character, all > that > 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 > work. > 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 > be > very grateful. > > > > /Robert > > > > > > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: > <http://mail.python.org/pipermail/tutor/attachments/20080817/f66af4dd/attachment-0001.htm> > _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor