mirror of
https://github.com/python/cpython.git
synced 2025-10-21 14:12:27 +00:00
Issue #8670: PyUnicode_AsWideChar() and PyUnicode_AsWideCharString() replace
UTF-16 surrogate pairs by single non-BMP characters for 16 bits Py_UNICODE and 32 bits wchar_t (eg. Linux in narrow build).
This commit is contained in:
parent
1c24bd0252
commit
5593d8aeb4
3 changed files with 131 additions and 24 deletions
|
@ -1419,6 +1419,17 @@ class UnicodeTest(string_tests.CommonTest,
|
|||
self.assertEquals(size, 7)
|
||||
self.assertEquals(wchar, 'abc\0def\0')
|
||||
|
||||
nonbmp = chr(0x10ffff)
|
||||
if sizeof(c_wchar) == 2:
|
||||
buflen = 3
|
||||
nchar = 2
|
||||
else: # sizeof(c_wchar) == 4
|
||||
buflen = 2
|
||||
nchar = 1
|
||||
wchar, size = test_aswidechar(nonbmp, buflen)
|
||||
self.assertEquals(size, nchar)
|
||||
self.assertEquals(wchar, nonbmp + '\0')
|
||||
|
||||
# Test PyUnicode_AsWideCharString()
|
||||
def test_aswidecharstring(self):
|
||||
from _testcapi import test_aswidecharstring
|
||||
|
@ -1432,6 +1443,15 @@ class UnicodeTest(string_tests.CommonTest,
|
|||
self.assertEquals(size, 7)
|
||||
self.assertEquals(wchar, 'abc\0def\0')
|
||||
|
||||
nonbmp = chr(0x10ffff)
|
||||
if sizeof(c_wchar) == 2:
|
||||
nchar = 2
|
||||
else: # sizeof(c_wchar) == 4
|
||||
nchar = 1
|
||||
wchar, size = test_aswidecharstring(nonbmp)
|
||||
self.assertEquals(size, nchar)
|
||||
self.assertEquals(wchar, nonbmp + '\0')
|
||||
|
||||
|
||||
def test_main():
|
||||
support.run_unittest(__name__)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue