cpython icon indicating copy to clipboard operation
cpython copied to clipboard

Tutorial: info on Source Code Encoding is missing

Open rnd0110 opened this issue 23 years ago • 3 comments

BPO 683486
Nosy @loewis, @rhettinger

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = 'https://github.com/loewis'
closed_at = <Date 2003-06-28.08:12:48.000>
created_at = <Date 2003-02-09.17:50:28.000>
labels = ['docs']
title = 'Tutorial: info on Source Code Encoding is missing'
updated_at = <Date 2003-06-28.08:12:48.000>
user = 'https://bugs.python.org/rnd0110'

bugs.python.org fields:

activity = <Date 2003-06-28.08:12:48.000>
actor = 'loewis'
assignee = 'loewis'
closed = True
closed_date = None
closer = None
components = ['Documentation']
creation = <Date 2003-02-09.17:50:28.000>
creator = 'rnd0110'
dependencies = []
files = []
hgrepos = []
issue_num = 683486
keywords = []
message_count = 3.0
messages = ['14537', '14538', '14539']
nosy_count = 3.0
nosy_names = ['loewis', 'rhettinger', 'rnd0110']
pr_nums = []
priority = 'normal'
resolution = 'accepted'
stage = None
status = 'closed'
superseder = None
type = None
url = 'https://bugs.python.org/issue683486'
versions = ['Python 2.3']

rnd0110 avatar Feb 09 '03 17:02 rnd0110

(I propose to add information into Tutorial on how to specify source code encoding. Please correct my English and maybe there is better way to get a list of possible encodings)

2.2.2 Executable Python Scripts

...

2.2.3 Source Code Encoding

It is possible to use encodings different than ASCII in Python source files. The best way to do it is to put one more special comment line right after #!-line making proper encoding declaration:

# -- coding: latin-1 --

After that, all characters in the source file will be treated as belonging to latin-1 encoding, and it will be possible to directly write Unicode strings in the selected encoding.

List of possible encodings could be found in the encodings subdirectory of Python directory.

Significant advantage could be had if using utf-8 encoding, as it allows to use letters from many languages in the same file.

2.2.4

rnd0110 avatar Feb 09 '03 17:02 rnd0110

Logged In: YES user_id=80475

Martin, I think something like the above wording should be added to the tutorial. Do you have any wording suggestions?

  • Instead of latin-1, it should list the ISO number.
  • The encodings directory is a subdirectory of Lib.
  • The last paragraph should be replaced and instead make your recommendation to arrange IDLE so that it always stores files as UTF-8 with BOM.

rhettinger avatar Jun 25 '03 18:06 rhettinger

Logged In: YES user_id=21627

I have added text in tut.tex 1.188 which was heavily inspired by Roman's text; thanks for contributing.