Commit 0ec2ff40 authored by Robert Bradshaw's avatar Robert Bradshaw

Docs for c_string_type and c_string_encoding

.# Please enter the commit message for your changes. Lines starting
parent 65ea99f4
......@@ -22,6 +22,9 @@ Features added
* Keyword arguments are supported for cdef functions.
* Added c_string_type and c_string_encoding directives to more easily convert between
Python and C strings.
Bugs fixed
----------
......
......@@ -208,6 +208,15 @@ Cython code. Here is the list of currently supported directives:
setting from the module being compiled, unless they explicitly
set their own language level.
``c_string_type`` (bytes / str / unicode)
Globally set the type of an implicit coercion from char* or std::string.
``c_string_encoding`` (ascii, default, utf-8, etc.)
Globally set the encoding to use when implicitly coercing char* or std:string
to a unicode object. Coercion from a unicode object to C type is only allowed
when set to ``ascii`` or ``default``, the latter being utf-8 in Python 3 and
nearly-always ascii in Python 2.
How to set directives
---------------------
......
......@@ -5,10 +5,12 @@ Unicode and passing strings
Similar to the string semantics in Python 3, Cython also strictly
separates byte strings and unicode strings. Above all, this means
that there is no automatic conversion between byte strings and unicode
strings (except for what Python 2 does in string operations). All
encoding and decoding must pass through an explicit encoding/decoding
step.
that by default there is no automatic conversion between byte strings
and unicode strings (except for what Python 2 does in string operations).
All encoding and decoding must pass through an explicit encoding/decoding
step. For simple cases, the module-level ``c_string_type`` and
``c_string_encoding`` directives can be used to implicitly insert these
encoding/decoding steps to ease conversion between Python and C strings.
General notes about C strings
-----------------------------
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment