summaryrefslogtreecommitdiff
path: root/docs/examples/tutorial/string/decode_cpp_string.pyx
diff options
context:
space:
mode:
authorgabrieldemarmiesse <gabriel.demarmiesse@teraki.com>2018-06-21 12:44:04 +0200
committergabrieldemarmiesse <gabriel.demarmiesse@teraki.com>2018-06-21 12:44:04 +0200
commit56f37f1dc99cf8987249251f9a9ab180eac8cdcc (patch)
treec394c624603cdcb528fe29edad2897888982fa25 /docs/examples/tutorial/string/decode_cpp_string.pyx
parent047809103580445f4dae65bb8c646dcd52231a10 (diff)
downloadcython-56f37f1dc99cf8987249251f9a9ab180eac8cdcc.tar.gz
Moved an example of decoding cpp strings to the examples directory.
Diffstat (limited to 'docs/examples/tutorial/string/decode_cpp_string.pyx')
-rw-r--r--docs/examples/tutorial/string/decode_cpp_string.pyx10
1 files changed, 10 insertions, 0 deletions
diff --git a/docs/examples/tutorial/string/decode_cpp_string.pyx b/docs/examples/tutorial/string/decode_cpp_string.pyx
new file mode 100644
index 000000000..8f1d01af8
--- /dev/null
+++ b/docs/examples/tutorial/string/decode_cpp_string.pyx
@@ -0,0 +1,10 @@
+# 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