From 7cbb1c2f19c1ff6de1773cb0b0b2cb3102382d9c Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Tue, 19 Dec 2006 21:04:01 +0000 Subject: [PATCH] Clarify encoding cookie format. --- pep-0263.txt | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/pep-0263.txt b/pep-0263.txt index 09521d8db..ae432e1d6 100644 --- a/pep-0263.txt +++ b/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= + + or (using formats recognized by popular editors) #!/usr/bin/python # -*- coding: -*- + or + + #!/usr/bin/python + # vim: set fileencoding= : + 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