[Tutor] unsupported characters

Lie Ryan lie.1296 at gmail.com
Mon Aug 18 12:18:27 CEST 2008


On Mon, 2008-08-18 at 17:15 +0700, Lie Ryan wrote:
> > 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)  :
> > 
> >  
> > 
> > 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>
> > 



More information about the Tutor mailing list