Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
cython
Commits
0ec2ff40
Commit
0ec2ff40
authored
Feb 26, 2013
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Docs for c_string_type and c_string_encoding
.# Please enter the commit message for your changes. Lines starting
parent
65ea99f4
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
4 deletions
+18
-4
CHANGES.rst
CHANGES.rst
+3
-0
docs/src/reference/compilation.rst
docs/src/reference/compilation.rst
+9
-0
docs/src/tutorial/strings.rst
docs/src/tutorial/strings.rst
+6
-4
No files found.
CHANGES.rst
View file @
0ec2ff40
...
...
@@ -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
----------
...
...
docs/src/reference/compilation.rst
View file @
0ec2ff40
...
...
@@ -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
---------------------
...
...
docs/src/tutorial/strings.rst
View file @
0ec2ff40
...
...
@@ -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
-----------------------------
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment