Clarify encoding cookie format.
This commit is contained in:
parent
1fc84c29cd
commit
7cbb1c2f19
13
pep-0263.txt
13
pep-0263.txt
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue