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
4603013c
Commit
4603013c
authored
Jul 03, 2010
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix order of surrogate pair in wide unicode strings
parent
f180a00f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
2 deletions
+15
-2
Cython/Compiler/StringEncoding.py
Cython/Compiler/StringEncoding.py
+1
-1
tests/run/unicodeliterals.pyx
tests/run/unicodeliterals.pyx
+14
-1
No files found.
Cython/Compiler/StringEncoding.py
View file @
4603013c
...
...
@@ -36,8 +36,8 @@ class UnicodeLiteralBuilder(object):
# wide Unicode character on narrow platform => replace
# by surrogate pair
char_number
-=
0x10000
self
.
chars
.
append
(
unichr
((
char_number
%
1024
)
+
0xDC00
)
)
self
.
chars
.
append
(
unichr
((
char_number
//
1024
)
+
0xD800
)
)
self
.
chars
.
append
(
unichr
((
char_number
%
1024
)
+
0xDC00
)
)
else
:
self
.
chars
.
append
(
unichr
(
char_number
)
)
else
:
...
...
tests/run/unicodeliterals.pyx
View file @
4603013c
# -*- coding: utf-8 -*-
import
sys
__doc__
=
br"""
>>> sa
'abc'
...
...
@@ -38,6 +40,12 @@ __doc__ = br"""
12
>>> len(null)
1
>>> sys.maxunicode >= 65535
True
>>> sys.maxunicode == 65535 and 1 or len(wide_literal) # test for wide build
1
>>> sys.maxunicode > 65535 and 2 or len(wide_literal) # test for narrow build
2
"""
.
decode
(
"ASCII"
)
+
u"""
>>> ua == u'abc'
True
...
...
@@ -59,9 +67,12 @@ __doc__ = br"""
True
>>> null == u'
\
\
x00' # unescaped by Python (required by doctest)
True
>>> wide_literal == u'
\
U00101234
' # unescaped by Cython
True
>>> wide_literal == u'
\
\
U00101234' # unescaped by Python
True
"""
import
sys
if
sys
.
version_info
[
0
]
>=
3
:
__doc__
=
__doc__
.
replace
(
u" u'"
,
u" '"
)
else
:
...
...
@@ -78,3 +89,5 @@ f = u'\xf8'
add
=
u'Søk ik'
+
u'üÖä'
+
u'abc'
null
=
u'
\
x00
'
wide_literal
=
u'
\
U00101234
'
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