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
Boxiang Sun
cython
Commits
f372acae
Commit
f372acae
authored
Feb 24, 2014
by
Mikhail Korobov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
DOC fix deprecated imports in "Unicode and passing strings" tutorial
parent
120fe47b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
5 deletions
+4
-5
docs/src/tutorial/strings.rst
docs/src/tutorial/strings.rst
+4
-5
No files found.
docs/src/tutorial/strings.rst
View file @
f372acae
...
...
@@ -139,13 +139,13 @@ exception, e.g. due to insufficient memory. If you need to
:c:func:`free()` the string after the conversion, you should wrap
the assignment in a try-finally construct::
cimport stdlib
from libc.stdlib cimport free
cdef bytes py_string
cdef char* c_string = c_call_creating_a_new_c_string()
try:
py_string = c_string
finally:
stdlib.
free(c_string)
free(c_string)
To convert the byte string back into a C :c:type:`char*`, use the
opposite assignment::
...
...
@@ -376,8 +376,7 @@ conversions in general) in dedicated functions, as this needs to be
done in exactly the same way whenever receiving text from C. This
could look as follows::
cimport python_unicode
cimport stdlib
from libc.stdlib cimport free
cdef unicode tounicode(char* s):
return s.decode('UTF-8', 'strict')
...
...
@@ -811,7 +810,7 @@ Here is an example of how one would call a Unicode API on Windows::
ctypedef const WCHAR* LPCWSTR
ctypedef void* HWND
int MessageBoxW(HWND hWnd, LPCWSTR lpText, LPCWSTR lpCaption, int uType)
int MessageBoxW(HWND hWnd, LPCWSTR lpText, LPCWSTR lpCaption, int uType)
title = u"Windows Interop Demo - Python %d.%d.%d" % sys.version_info[:3]
MessageBoxW(NULL, u"Hello Cython \u263a", title, 0)
...
...
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