Clarify encoding cookie format.

This commit is contained in:
Georg Brandl 2006-12-19 21:04:01 +00:00
parent 1fc84c29cd
commit 7cbb1c2f19
1 changed files with 11 additions and 2 deletions

View File

@ -47,17 +47,26 @@ Defining the Encoding
To define a source code encoding, a magic comment must
be placed into the source files either as first or second
line in the file:
line in the file, such as:
# coding=<encoding name>
or (using formats recognized by popular editors)
#!/usr/bin/python
# -*- coding: <encoding name> -*-
or
#!/usr/bin/python
# vim: set fileencoding=<encoding name> :
More precisely, the first or second line must match the regular
expression "coding[:=]\s*([-\w.]+)". The first group of this
expression is then interpreted as encoding name. If the encoding
is unknown to Python, an error is raised during compilation. There
must not be any Python statement on the line that contains the
encoding declartation.
encoding declaration.
To aid with platforms such as Windows, which add Unicode BOM marks
to the beginning of Unicode files, the UTF-8 signature