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
Kirill Smelkov
cython
Commits
56f37f1d
Commit
56f37f1d
authored
Jun 21, 2018
by
gabrieldemarmiesse
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Moved an example of decoding cpp strings to the examples directory.
parent
04780910
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
5 deletions
+12
-5
docs/examples/tutorial/string/decode_cpp_string.pyx
docs/examples/tutorial/string/decode_cpp_string.pyx
+10
-0
docs/src/tutorial/strings.rst
docs/src/tutorial/strings.rst
+2
-5
No files found.
docs/examples/tutorial/string/decode_cpp_string.pyx
0 → 100644
View file @
56f37f1d
# distutils: language = c++
from
libcpp.string
cimport
string
def
get_ustrings
():
cdef
string
s
=
string
(
b'abcdefg'
)
ustring1
=
s
.
decode
(
'UTF-8'
)
ustring2
=
s
[
2
:
-
2
].
decode
(
'UTF-8'
)
return
ustring1
,
ustring2
docs/src/tutorial/strings.rst
View file @
56f37f1d
...
@@ -392,12 +392,9 @@ the Unicode string into a temporarily created Python bytes object
...
@@ -392,12 +392,9 @@ the Unicode string into a temporarily created Python bytes object
and then copies its buffer into a new C++ string.
and then copies its buffer into a new C++ string.
For the other direction, efficient decoding support is available
For the other direction, efficient decoding support is available
in Cython 0.17 and later:
:
in Cython 0.17 and later:
cdef string s = string(b'abcdefg')
.. literalinclude:: ../../examples/tutorial/string/decode_cpp_string.pyx
ustring1 = s.decode('UTF-8')
ustring2 = s[2:-2].decode('UTF-8')
For C++ strings, decoding slices will always take the proper length
For C++ strings, decoding slices will always take the proper length
of the string into account and apply Python slicing semantics (e.g.
of the string into account and apply Python slicing semantics (e.g.
...
...
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