Skip to content

Commit 5bf0153

Browse files
committed
Test a default (= UTF-8) encode and decode
1 parent c962057 commit 5bf0153

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

tests/basics/unicode.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
s = "asdf©qwer"
33
for i in range(len(s)):
44
print("s[%d]: %s %X"%(i, s[i], ord(s[i])))
5+
56
# Test all three forms of Unicode escape, and
67
# all blocks of UTF-8 byte patterns
78
s = "a\xA9\xFF\u0123\u0800\uFFEE\U0001F44C"
@@ -11,3 +12,7 @@
1112
for j in range(i, len(s)):
1213
print("s[%d:%d]: %d chars, '%s'"%(i, j, len(s[i:j]), s[i:j]))
1314
print("s[%d:]: %d chars, '%s'"%(i, len(s[i:]), s[i:]))
15+
16+
# Test UTF-8 encode and decode
17+
enc = s.encode()
18+
print(enc, enc.decode() == s)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy