Trouble with source-code encoding

F

Fernando Rodriguez

Hi,

I just upgraded to Python2.3 and I'm getting a weird warning complaining about
the encoding and asking me to read a pep. OK, I read the Pep and know what
syntax to specify the enconding:
# -*- coding: <encoding name> -*-

However, th epep doesn't list the name of valid encodings. What's the name
for west european encoding?
 
A

Alan Kennedy

Fernando said:
However, the pep doesn't list the name of valid encodings. What's
the name for west european encoding?

Unfortunately, there is no way, from code, to get a list of valid
encodings.

You can get a good idea of supported encodings, their names and
various aliases, by looking at the source of

Lib/encodings/aliases.py

which gives the following list of possible names for the "latin_1"
codec

'8859'
'cp819'
'csisolatin1'
'ibm819'
'iso8859'
'iso_8859_1'
'iso_8859_1_1987'
'iso_ir_100'
'l1'
'latin'
'latin1'

Any of those should work as your script encoding.
 
S

Skip Montanaro

Fernando> I just upgraded to Python2.3 and I'm getting a weird warning complaining about
Fernando> the encoding and asking me to read a pep. OK, I read the Pep and know what
Fernando> syntax to specify the enconding:
Fernando> # -*- coding: <encoding name> -*-

Fernando> However, th epep doesn't list the name of valid encodings.
Fernando> What's the name for west european encoding?

That would be

# -*- coding: latin1 -*-

or

# -*- coding: iso8859-1 -*-

I believe.

Skip
 
M

Martin v. =?iso-8859-15?q?L=F6wis?=

Fernando Rodriguez said:
However, th epep doesn't list the name of valid encodings. What's
the name for west european encoding?

There is more than one west european encoding. Most common are
"iso-8859-1" (also known as "latin-1"), "cp1252" (aka "windows-1252"),
and "utf-8".

Regards,
Martin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,163
Messages
2,570,897
Members
47,435
Latest member
PhilipBelm

Latest Threads

Top