Minor spelling fixes
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Jason Davies · committed by Armin Ronacher · parent 2ac1b7d · Browse files · 3 files·+17 added−17 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Trailers
- Signed-off-by: Armin Ronacher <armin.ronacher@active-4.com>
Diff stats
3 files+17 added−17 removed
- other:+17 added−17 removed
Provenance
- Commit
ed517c7- Tree
6d0f4d0- Author
Jason Davies <jason@jasondavies.com>- Committer
Armin Ronacher <armin.ronacher@active-4.com>- Parent
2ac1b7d
3 files changed+17 added−17 removed
modified:docs/foreword.rst+1 added-1 removed
104 unmodified lines105 Werkzeug and Flask will be ported to Python 3 as soon as a solution for106 WSGI is found, and we will provide helpful tips how to upgrade existing107 applications to Python 3. Until then, we strongly recommend using Python108 2.6 and 2.7 with activated Python 3 warnings during development, as well109-as the unicode literals `__future__` feature.109+as the Unicode literals `__future__` feature.modified:docs/unicode.rst+14 added-14 removed
1 Unicode in Flask2 ================3 4-Flask like Jinja2 and Werkzeug is totally unicode based when it comes to4+Flask like Jinja2 and Werkzeug is totally Unicode based when it comes to5 text. Not only these libraries, also the majority of web related Python6-libraries that deal with text. If you don't know unicode so far, you6+libraries that deal with text. If you don't know Unicode so far, you7 should probably read `The Absolute Minimum Every Software Developer8 Absolutely, Positively Must Know About Unicode and Character Sets9 <http://www.joelonsoftware.com/articles/Unicode.html>`_. This part of the10 documentation just tries to cover the very basics so that you have a11-pleasant experience with unicode related things.11+pleasant experience with Unicode related things.12 13 Automatic Conversion14 --------------------15 16 Flask has a few assumptions about your application (which you can change17-of course) that give you basic and painless unicode support:17+of course) that give you basic and painless Unicode support:18 19 - the encoding for text on your website is UTF-820-- internally you will always use unicode exclusively for text except20+- internally you will always use Unicode exclusively for text except21 for literal strings with only ASCII character points.22 - encoding and decoding happens whenever you are talking over a protocol23 that requires bytes to be transmitted.24 3 unmodified lines28 address documents on servers (so called URIs or URLs). However HTML which29 is usually transmitted on top of HTTP supports a large variety of30 character sets and which ones are used, are transmitted in an HTTP header.31 To not make this too complex Flask just assumes that if you are sending32-unicode out you want it to be UTF-8 encoded. Flask will do the encoding32+Unicode out you want it to be UTF-8 encoded. Flask will do the encoding33 and setting of the appropriate headers for you.34 35 The same is true if you are talking to databases with the help of36 SQLAlchemy or a similar ORM system. Some databases have a protocol that37-already transmits unicode and if they do not, SQLAlchemy or your other ORM37+already transmits Unicode and if they do not, SQLAlchemy or your other ORM38 should take care of that.39 40 The Golden Rule41 ---------------42 43 So the rule of thumb: if you are not dealing with binary data, work with44-unicode. What does working with unicode in Python 2.x mean?44+Unicode. What does working with Unicode in Python 2.x mean?45 46 - as long as you are using ASCII charpoints only (basically numbers,47 some special characters of latin letters without umlauts or anything48 fancy) you can use regular string literals (``'Hello World'``).49 - if you need anything else than ASCII in a string you have to mark50- this string as unicode string by prefixing it with a lowercase `u`.50+ this string as Unicode string by prefixing it with a lowercase `u`.51 (like ``u'Hänsel und Gretel'``)52-- if you are using non-unicode characters in your Python files you have52+- if you are using non-Unicode characters in your Python files you have53 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.3 unmodified lines60 Encoding and Decoding Yourself61 ------------------------------62 63 If you are talking with a filesystem or something that is not really based64-on unicode you will have to ensure that you decode properly when working65-with unicode interface. So for example if you want to load a file on the64+on Unicode you will have to ensure that you decode properly when working65+with Unicode interface. So for example if you want to load a file on the66 filesystem and embed it into a Jinja2 template you will have to decode it67 from the encoding of that file. Here the old problem that text files do68 not specify their encoding comes into play. So do yourself a favour and69 limit yourself to UTF-8 for text files as well.70 71-Anyways. To load such a file with unicode you can use the built-in71+Anyways. To load such a file with Unicode you can use the built-in72 :meth:`str.decode` method::73 74 def read_file(filename, charset='utf-8'):75 with open(filename, 'r') as f:76 return f.read().decode(charset)77 78-To go from unicode into a specific charset such as UTF-8 you can use the78+To go from Unicode into a specific charset such as UTF-8 you can use the79 :meth:`unicode.encode` method::80 81 def write_file(filename, contents, charset='utf-8'):82 with open(filename, 'w') as f:25 unmodified linesmodified:CHANGES+2 added-2 removed
43 unmodified lines44 45 - after request functions are now called in reverse order of46 registration.47 - OPTIONS is now automatically implemented by Flask unless the48- application explictly adds 'OPTIONS' as method to the URL rule.48+ application explicitly adds 'OPTIONS' as method to the URL rule.49 In this case no automatic OPTIONS handling kicks in.50 - static rules are now even in place if there is no static folder51 for the module. This was implemented to aid GAE which will52 remove the static folder if it's part of a mapping in the .yml11 unmodified lines64 creating response object instances in views.65 - added signalling support based on blinker. This feature is currently66 optional and supposed to be used by extensions and applications. If67 you want to use it, make sure to have `blinker`_ installed.68-- refactored the way url adapters are created. This process is now68+- refactored the way URL adapters are created. This process is now69 fully customizable with the :meth:`~flask.Flask.create_url_adapter`70 method.71 - modules can now register for a subdomain instead of just an URL72 prefix. This makes it possible to bind a whole module to a113 unmodified lines