Skip to content
Myr

Added a section about unicode and editors. This fixes #74

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Armin Ronacher · committed by Armin Ronacher · parent d0357b4 · Browse files · 2 files+26 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+26 added−0 removed

  • other:+26 added−0 removed

2 files+26 added−0 removed

modified:docs/_themesnot shown

Its text is not shown, modified.

modified:docs/unicode.rst+26 added
52 unmodified lines
53 to tell Python which encoding your file uses. Again, I recommend54 UTF-8 for this purpose. To tell the interpreter your encoding you can55 put the ``# -*- coding: utf-8 -*-`` into the first or second line of56 your Python source file.57- Jinja is configured to decode the template files from UTF08. So make58 sure to tell your editor to save the file as UTF-8 there as well.5960Encoding and Decoding Yourself61------------------------------62
17 unmodified lines
8081 def write_file(filename, contents, charset='utf-8'):82 with open(filename, 'w') as f:83 f.write(contents.encode(charset))8485Configuring Editors86-------------------8788Most editors save as UTF-8 by default nowadays but in case your editor is89not configured to do this you have to change it. Here some common ways to90set your editor to store as UTF-8:9192- Vim: put ``set enc=utf-8`` to your ``.vimrc`` file.9394- Emacs: either use an encoding cookie or put this into your ``.emacs``95 file::9697 (prefer-coding-system 'utf-8)98 (setq default-buffer-file-coding-system 'utf-8)99100- Notepad++:101102 1. Go to *Settings -> Preferences ...*103 2. Select the "New Document/Default Directory" tab104 3. Select "UTF-8 without BOM" as encoding105106 It is also recommended to use the Unix newline format, you can select107 it in the same panel but this not a requirement.