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
53500f4e
Commit
53500f4e
authored
Jun 22, 2018
by
scoder
Committed by
GitHub
Jun 22, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2386 from gabrieldemarmiesse/test_string_11
Adding tests for "Unicode and passing strings" part 11
parents
038812a7
56f37f1d
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 @
53500f4e
# 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 @
53500f4e
...
...
@@ -363,12 +363,9 @@ the Unicode string into a temporarily created Python bytes object
and then copies its buffer into a new C++ string.
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')
ustring1 = s.decode('UTF-8')
ustring2 = s[2:-2].decode('UTF-8')
.. literalinclude:: ../../examples/tutorial/string/decode_cpp_string.pyx
For C++ strings, decoding slices will always take the proper length
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