[Python-checkins] python/dist/src/Doc/tut tut.tex,1.254,1.255

fdrake at users.sourceforge.net fdrake at users.sourceforge.net
Mon Oct 25 18:03:53 CEST 2004

Update of /cvsroot/python/python/dist/src/Doc/tut
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20744

Modified Files:
Log Message:
- improve the explanation of the -*- coding: ... -*- marker
- fix a minor formatting nit that affected the typeset version

Index: tut.tex
RCS file: /cvsroot/python/python/dist/src/Doc/tut/tut.tex,v
retrieving revision 1.254
retrieving revision 1.255
diff -u -d -r1.254 -r1.255
--- tut.tex	7 Oct 2004 06:46:22 -0000	1.254
+++ tut.tex	25 Oct 2004 16:03:49 -0000	1.255
@@ -1,5 +1,6 @@
 % Things to do:
 % Should really move the Python startup file info to an appendix
@@ -326,28 +327,41 @@
 files. The best way to do it is to put one more special comment line
 right after the \code{\#!} line to define the source file encoding:
-# -*- coding: iso-8859-1 -*- 
+# -*- coding: \var{encoding} -*- 
 With that declaration, all characters in the source file will be treated as
-{}\code{iso-8859-1}, and it will be
+having the encoding \var{encoding}, and it will be
 possible to directly write Unicode string literals in the selected
 encoding.  The list of possible encodings can be found in the
 \citetitle[../lib/lib.html]{Python Library Reference}, in the section
 on \ulink{\module{codecs}}{../lib/module-codecs.html}.
+For example, to write Unicode literals including the Euro currency
+symbol, the ISO-8859-15 encoding can be used, with the Euro symbol
+having the ordinal value 164.  This script will print the value 8364
+(the Unicode codepoint corresponding to the Euro symbol) and then
+# -*- coding: iso-8859-15 -*-
+currency = u"\texteuro"
+print ord(currency)
 If your editor supports saving files as \code{UTF-8} with a UTF-8
 \emph{byte order mark} (aka BOM), you can use that instead of an
 encoding declaration. IDLE supports this capability if
 \code{Options/General/Default Source Encoding/UTF-8} is set. Notice
 that this signature is not understood in older Python releases (2.2
 and earlier), and also not understood by the operating system for
-\code{\#!} files.
+script files with \code{\#!} lines (only used on \UNIX{} systems).
 By using UTF-8 (either through the signature or an encoding
 declaration), characters of most languages in the world can be used
-simultaneously in string literals and comments. Using non-\ASCII
+simultaneously in string literals and comments.  Using non-\ASCII{}
 characters in identifiers is not supported. To display all these
 characters properly, your editor must recognize that the file is
 UTF-8, and it must use a font that supports all the characters in the

More information about the Python-checkins mailing list