Commit 53500f4e authored by scoder's avatar scoder Committed by GitHub

Merge pull request #2386 from gabrieldemarmiesse/test_string_11

Adding tests for "Unicode and passing strings" part 11
parents 038812a7 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
......@@ -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.
......
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