Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
0290c7a8
Commit
0290c7a8
authored
Nov 11, 2011
by
Antoine Pitrou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix regression on 2-byte wchar_t systems (Windows)
parent
28a08205
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
7 deletions
+12
-7
Objects/unicodeobject.c
Objects/unicodeobject.c
+12
-7
No files found.
Objects/unicodeobject.c
View file @
0290c7a8
...
...
@@ -6252,15 +6252,18 @@ _PyUnicode_DecodeUnicodeInternal(const char *s,
end
=
s
+
size
;
while
(
s
<
end
)
{
Py_UNICODE
uch
;
Py_UCS4
ch
;
/* We copy the raw representation one byte at a time because the
pointer may be unaligned (see test_codeccallbacks). */
((
char
*
)
&
ch
)[
0
]
=
s
[
0
];
((
char
*
)
&
ch
)[
1
]
=
s
[
1
];
((
char
*
)
&
u
ch
)[
0
]
=
s
[
0
];
((
char
*
)
&
u
ch
)[
1
]
=
s
[
1
];
#ifdef Py_UNICODE_WIDE
((
char
*
)
&
ch
)[
2
]
=
s
[
2
];
((
char
*
)
&
ch
)[
3
]
=
s
[
3
];
((
char
*
)
&
u
ch
)[
2
]
=
s
[
2
];
((
char
*
)
&
u
ch
)[
3
]
=
s
[
3
];
#endif
ch
=
uch
;
/* We have to sanity check the raw data, otherwise doom looms for
some malformed UCS-4 data. */
if
(
...
...
@@ -6292,10 +6295,12 @@ _PyUnicode_DecodeUnicodeInternal(const char *s,
#ifndef Py_UNICODE_WIDE
if
(
ch
>=
0xD800
&&
ch
<=
0xDBFF
&&
s
<
end
)
{
Py_UCS4
ch2
=
*
(
Py_UNICODE
*
)
s
;
if
(
ch2
>=
0xDC00
&&
ch2
<=
0xDFFF
)
Py_UNICODE
uch2
;
((
char
*
)
&
uch2
)[
0
]
=
s
[
0
];
((
char
*
)
&
uch2
)[
1
]
=
s
[
1
];
if
(
uch2
>=
0xDC00
&&
uch2
<=
0xDFFF
)
{
ch
=
(((
ch
&
0x3FF
)
<<
10
)
|
(
ch2
&
0x3FF
))
+
0x10000
;
ch
=
(((
uch
&
0x3FF
)
<<
10
)
|
(
u
ch2
&
0x3FF
))
+
0x10000
;
s
+=
Py_UNICODE_SIZE
;
}
}
...
...
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