Some tiny documentation fixes (unicode -> Unicode)
Before adoption: this commit came in with the history the project adopted, so no landing records it.
--HG-- branch : trunk
authored by Armin Ronacher · committed by Armin Ronacher · parent 88dc32c · Browse files · 2 files·+10 added−10 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+10 added−10 removed
- other:+10 added−10 removed
Provenance
- Commit
656d5e7- Tree
bccf96d- Author
Armin Ronacher <armin.ronacher@active-4.com>- Committer
Armin Ronacher <armin.ronacher@active-4.com>- Parent
88dc32c
2 files changed+10 added−10 removed
modified:docs/api.rst+9 added-9 removed
50 unmodified lines51 52 Unicode53 -------54 55-Jinja2 is using unicode internally which means that you have to pass unicode55+Jinja2 is using Unicode internally which means that you have to pass Unicode56 objects to the render function or bytestrings that only consist of ASCII57 characters. Additionally newlines are normalized to one end of line58 sequence which is per default UNIX style (``\n``).59 3 unmodified lines63 be used to store text based information unless only ASCII characters are64 used. With Python 2.6 it is possible to make `unicode` the default on a per65 module level and with Python 3 it will be the default.66 67-To explicitly use a unicode string you have to prefix the string literal67+To explicitly use a Unicode string you have to prefix the string literal68 with a `u`: ``u'Hänsel und Gretel sagen Hallo'``. That way Python will69-store the string as unicode by decoding the string with the character69+store the string as Unicode by decoding the string with the character70 encoding from the current Python module. If no encoding is specified this71 defaults to 'ASCII' which means that you can't use any non ASCII identifier.72 73 To set a better module encoding add the following comment to the first or74-second line of the Python module using the unicode literal::74+second line of the Python module using the Unicode literal::75 76 # -*- coding: utf-8 -*-77 78 We recommend utf-8 as Encoding for Python modules and templates as it's79 possible to represent every Unicode character in utf-8 and because it's80 backwards compatible to ASCII. For Jinja2 the default encoding of templates81 is assumed to be utf-8.82 83-It is not possible to use Jinja2 to process non unicode data. The reason83+It is not possible to use Jinja2 to process non-Unicode data. The reason84 for this is that Jinja2 uses Unicode already on the language level. For85 example Jinja2 treats the non-breaking space as valid whitespace inside86 expressions which requires knowledge of the encoding or operating on an87-unicode string.87+Unicode string.88 89-For more details about unicode in Python have a look at the excellent89+For more details about Unicode in Python have a look at the excellent90 `Unicode documentation`_.91 92 Another important thing is how Jinja2 is handling string literals in93-templates. A naive implementation would be using unicode strings for93+templates. A naive implementation would be using Unicode strings for94 all string literals but it turned out in the past that this is problematic95 as some libraries are typechecking against `str` explicitly. For example96-`datetime.strftime` does not accept unicode arguments. To not break it96+`datetime.strftime` does not accept Unicode arguments. To not break it97 completely Jinja2 is returning `str` for strings that fit into ASCII and98 for everything else `unicode`:99 100 >>> m = Template(u"{% set a, b = 'foo', 'föö' %}").module584 unmodified linesmodified:docs/intro.rst+1 added-1 removed
35 unmodified lines36 that can create python extensions should be installed for the debugger. If no37 C-compiler is available and you are using Python 2.4 the `ctypes`_ module38 should be installed.39 40-If you don't have a working C compiler and you are trying to install the source40+If you don't have a working C-compiler and you are trying to install the source41 release with the speedups you will get a compiler error. This however can be42 circumvented by passing the ``--without-speedups`` command line argument to the43 setup script::44 109 unmodified lines