Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
9765efcb
Kaydet (Commit)
9765efcb
authored
Haz 14, 2019
tarafından
Zackery Spytz
Kaydeden (comit)
Victor Stinner
Haz 14, 2019
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
bpo-19865: ctypes.create_unicode_buffer() supports non-BMP strings on Windows (GH-14081)
üst
21a92f8c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
1 deletion
+20
-1
__init__.py
Lib/ctypes/__init__.py
+9
-1
test_buffers.py
Lib/ctypes/test/test_buffers.py
+9
-0
2019-06-14-08-30-16.bpo-19865.FRGH4I.rst
...S.d/next/Library/2019-06-14-08-30-16.bpo-19865.FRGH4I.rst
+2
-0
No files found.
Lib/ctypes/__init__.py
Dosyayı görüntüle @
9765efcb
...
...
@@ -274,7 +274,15 @@ def create_unicode_buffer(init, size=None):
"""
if
isinstance
(
init
,
str
):
if
size
is
None
:
size
=
len
(
init
)
+
1
if
sizeof
(
c_wchar
)
==
2
:
# UTF-16 requires a surrogate pair (2 wchar_t) for non-BMP
# characters (outside [U+0000; U+FFFF] range). +1 for trailing
# NUL character.
size
=
sum
(
2
if
ord
(
c
)
>
0xFFFF
else
1
for
c
in
init
)
+
1
else
:
# 32-bit wchar_t (1 wchar_t per Unicode character). +1 for
# trailing NUL character.
size
=
len
(
init
)
+
1
buftype
=
c_wchar
*
size
buf
=
buftype
()
buf
.
value
=
init
...
...
Lib/ctypes/test/test_buffers.py
Dosyayı görüntüle @
9765efcb
...
...
@@ -60,5 +60,14 @@ class StringBufferTestCase(unittest.TestCase):
self
.
assertEqual
(
b
[::
2
],
"ac"
)
self
.
assertEqual
(
b
[::
5
],
"a"
)
@need_symbol
(
'c_wchar'
)
def
test_create_unicode_buffer_non_bmp
(
self
):
expected
=
5
if
sizeof
(
c_wchar
)
==
2
else
3
for
s
in
'
\U00010000\U00100000
'
,
'
\U00010000\U0010ffff
'
:
b
=
create_unicode_buffer
(
s
)
self
.
assertEqual
(
len
(
b
),
expected
)
self
.
assertEqual
(
b
[
-
1
],
'
\0
'
)
if
__name__
==
"__main__"
:
unittest
.
main
()
Misc/NEWS.d/next/Library/2019-06-14-08-30-16.bpo-19865.FRGH4I.rst
0 → 100644
Dosyayı görüntüle @
9765efcb
:func:`ctypes.create_unicode_buffer()` now also supports non-BMP characters
on platforms with 16-bit :c:type:`wchar_t` (for example, Windows and AIX).
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