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
Gwenaël Samain
cython
Commits
c36e1d35
Commit
c36e1d35
authored
Jun 19, 2018
by
gabrieldemarmiesse
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Moved an example from the string.rst to the examples directory.
parent
5c04c1a8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
9 deletions
+10
-9
docs/examples/tutorial/string/to_char.pyx
docs/examples/tutorial/string/to_char.pyx
+8
-0
docs/src/tutorial/strings.rst
docs/src/tutorial/strings.rst
+2
-9
No files found.
docs/examples/tutorial/string/to_char.pyx
0 → 100644
View file @
c36e1d35
# define a global name for whatever char type is used in the module
ctypedef
unsigned
char
char_type
cdef
char_type
[:]
_chars
(
s
):
if
isinstance
(
s
,
unicode
):
# encode to the specific encoding used inside of the module
s
=
(
<
unicode
>
s
).
encode
(
'utf8'
)
return
s
docs/src/tutorial/strings.rst
View file @
c36e1d35
...
@@ -275,16 +275,9 @@ And should then be used like this::
...
@@ -275,16 +275,9 @@ And should then be used like this::
Similarly, if the further processing happens at the byte level, but Unicode
Similarly, if the further processing happens at the byte level, but Unicode
string input should be accepted, then the following might work, if you are
string input should be accepted, then the following might work, if you are
using memory views:
:
using memory views:
# define a global name for whatever char type is used in the module
.. literalinclude:: ../../examples/tutorial/string/to_char.pyx
ctypedef unsigned char char_type
cdef char_type[:] _chars(s):
if isinstance(s, unicode):
# encode to the specific encoding used inside of the module
s = (<unicode>s).encode('utf8')
return s
In this case, you might want to additionally ensure that byte string
In this case, you might want to additionally ensure that byte string
input really uses the correct encoding, e.g. if you require pure ASCII
input really uses the correct encoding, e.g. if you require pure ASCII
...
...
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