Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
2
Task/String-length/Python/string-length-1.py
Normal file
2
Task/String-length/Python/string-length-1.py
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
print len('ascii')
|
||||
# 5
|
||||
2
Task/String-length/Python/string-length-10.py
Normal file
2
Task/String-length/Python/string-length-10.py
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
print(len("𝔘𝔫𝔦𝔠𝔬𝔡𝔢"))
|
||||
# 7
|
||||
2
Task/String-length/Python/string-length-11.py
Normal file
2
Task/String-length/Python/string-length-11.py
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
import sys
|
||||
sys.maxunicode # 1114111 on a wide build, 65535 on a narrow build
|
||||
4
Task/String-length/Python/string-length-12.py
Normal file
4
Task/String-length/Python/string-length-12.py
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
print(len('ascii'))
|
||||
# 5
|
||||
print(len('\u05d0')) # the letter Alef as unicode literal
|
||||
# 1
|
||||
2
Task/String-length/Python/string-length-13.py
Normal file
2
Task/String-length/Python/string-length-13.py
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
print(len(b'\xd7\x90'.decode('utf-8'))) # Alef encoded as utf-8 byte sequence
|
||||
# 1
|
||||
2
Task/String-length/Python/string-length-14.py
Normal file
2
Task/String-length/Python/string-length-14.py
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
print(hex(sys.maxunicode), len(unichr(0x1F4A9)))
|
||||
# ('0x10ffff', 1)
|
||||
2
Task/String-length/Python/string-length-15.py
Normal file
2
Task/String-length/Python/string-length-15.py
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
print(hex(sys.maxunicode), len(unichr(0x1F4A9)))
|
||||
# ('0xffff', 2)
|
||||
5
Task/String-length/Python/string-length-2.py
Normal file
5
Task/String-length/Python/string-length-2.py
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
# The letter Alef
|
||||
print len(u'\u05d0'.encode('utf-8'))
|
||||
# 2
|
||||
print len(u'\u05d0'.encode('iso-8859-8'))
|
||||
# 1
|
||||
6
Task/String-length/Python/string-length-3.py
Normal file
6
Task/String-length/Python/string-length-3.py
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
#!/bin/env python
|
||||
# -*- coding: UTF-8 -*-
|
||||
s = u"møøse"
|
||||
assert len(s) == 5
|
||||
assert len(s.encode('UTF-8')) == 7
|
||||
assert len(s.encode('UTF-16-BE')) == 10 # There are 3 different UTF-16 encodings: LE and BE are little endian and big endian respectively, the third one (without suffix) adds 2 extra leading bytes: the byte-order mark (BOM).
|
||||
2
Task/String-length/Python/string-length-4.py
Normal file
2
Task/String-length/Python/string-length-4.py
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
import sys
|
||||
sys.maxunicode # 1114111 on a wide build, 65535 on a narrow build
|
||||
8
Task/String-length/Python/string-length-5.py
Normal file
8
Task/String-length/Python/string-length-5.py
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
print len('ascii')
|
||||
# 5
|
||||
print len(u'\u05d0') # the letter Alef as unicode literal
|
||||
# 1
|
||||
print len('\xd7\x90'.decode('utf-8')) # Same encoded as utf-8 string
|
||||
# 1
|
||||
print hex(sys.maxunicode), len(unichr(0x1F4A9))
|
||||
# ('0x10ffff', 1)
|
||||
2
Task/String-length/Python/string-length-6.py
Normal file
2
Task/String-length/Python/string-length-6.py
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
print hex(sys.maxunicode), len(unichr(0x1F4A9))
|
||||
# ('0xffff', 2)
|
||||
2
Task/String-length/Python/string-length-7.py
Normal file
2
Task/String-length/Python/string-length-7.py
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
print(len(b'Hello, World!'))
|
||||
# 13
|
||||
5
Task/String-length/Python/string-length-8.py
Normal file
5
Task/String-length/Python/string-length-8.py
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
# The letter Alef
|
||||
print(len('\u05d0'.encode())) # the default encoding is utf-8 in Python3
|
||||
# 2
|
||||
print(len('\u05d0'.encode('iso-8859-8')))
|
||||
# 1
|
||||
9
Task/String-length/Python/string-length-9.py
Normal file
9
Task/String-length/Python/string-length-9.py
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
#!/bin/env python
|
||||
# -*- coding: UTF-8 -*-
|
||||
s = "møøse"
|
||||
assert len(s) == 5
|
||||
assert len(s.encode('UTF-8')) == 7
|
||||
assert len(s.encode('UTF-16-BE')) == 10 # There are 3 different UTF-16 encodings: LE and BE are little endian and big endian respectively, the third one (without suffix) adds 2 extra leading bytes: the byte-order mark (BOM).
|
||||
u="𝔘𝔫𝔦𝔠𝔬𝔡𝔢"
|
||||
assert len(u.encode()) == 28
|
||||
assert len(u.encode('UTF-16-BE')) == 28
|
||||
Loading…
Add table
Add a link
Reference in a new issue