Clarify things around the coding cookie.
Serhiy Storchaka: "Coding cookie must be in comment, only the first occurrence in the line must be taken to account (here is a bug in CPython), encoding name must be ASCII, and there must not be any Python statement on the line that contains the encoding declaration."
This commit is contained in:
parent
cbf79d2711
commit
e8c05569ec
|
@ -61,11 +61,13 @@ Defining the Encoding
|
|||
# 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 "^[ \t\v]*#.*?coding[:=][ \t]*([-.a-zA-Z0-9]+)".
|
||||
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 declaration.
|
||||
encoding declaration. If the first line matches the second line
|
||||
is ignored.
|
||||
|
||||
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