mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
Normalize the encoding names for Latin-1 and UTF-8 to
'latin-1' and 'utf-8'. These are optimized in the Python Unicode implementation to result in more direct processing, bypassing the codec registry. Also see issue11303.
This commit is contained in:
parent
a391b11320
commit
8f36af7a4c
32 changed files with 84 additions and 79 deletions
|
@ -1182,11 +1182,14 @@ class UnicodeTest(string_tests.CommonTest,
|
|||
self.assertEqual('hello'.encode('ascii'), b'hello')
|
||||
self.assertEqual('hello'.encode('utf-7'), b'hello')
|
||||
self.assertEqual('hello'.encode('utf-8'), b'hello')
|
||||
self.assertEqual('hello'.encode('utf8'), b'hello')
|
||||
self.assertEqual('hello'.encode('utf-8'), b'hello')
|
||||
self.assertEqual('hello'.encode('utf-16-le'), b'h\000e\000l\000l\000o\000')
|
||||
self.assertEqual('hello'.encode('utf-16-be'), b'\000h\000e\000l\000l\000o')
|
||||
self.assertEqual('hello'.encode('latin-1'), b'hello')
|
||||
|
||||
# Default encoding is utf-8
|
||||
self.assertEqual('\u2603'.encode(), b'\xe2\x98\x83')
|
||||
|
||||
# Roundtrip safety for BMP (just the first 1024 chars)
|
||||
for c in range(1024):
|
||||
u = chr(c)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue