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
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
db4876c8
Commit
db4876c8
authored
May 04, 2010
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
additional example, minor clarification
parent
836aa220
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
5 deletions
+11
-5
src/tutorial/strings.rst
src/tutorial/strings.rst
+11
-5
No files found.
src/tutorial/strings.rst
View file @
db4876c8
...
...
@@ -189,7 +189,7 @@ As a rule of thumb, it is best to avoid unprefixed non-ASCII ``str``
literals and to use unicode string literals for all text. Cython also
supports the ``__future__`` import ``unicode_literals`` that instructs
the parser to read all unprefixed ``str`` literals in a source file as
unicode string literals.
unicode string literals
, just like Python 3
.
.. _`CEP 108`: http://wiki.cython.org/enhancements/stringliterals
...
...
@@ -257,15 +257,21 @@ Cython 0.13 supports efficient iteration over ``char*``, bytes and
unicode strings, as long as the loop variable is appropriately typed.
So the following will generate the expected C code::
# -*- coding: ASCII -*-
cdef char* c_string = c_call_returning_a_c_string()
cdef char* c_string = ...
cdef char c
for c in c_string[:100]:
if c == 'A': ...
The same applies to unicode objects::
The same applies to bytes objects::
cdef bytes bytes_string = ...
cdef char c
for c in bytes_string:
if c == 'A': ...
and unicode objects::
cdef unicode ustring = ...
...
...
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