@@ -16,27 +16,27 @@ def make_string(seq: Union[bytes, list]) -> str:
16
16
"""
17
17
Don't throw an exception when given an out of range character.
18
18
"""
19
- string = ''
20
- for char in seq :
21
- # Screen out non-printing characters
22
- try :
23
- if 32 <= char < 256 :
24
- string += chr (char )
25
- except TypeError :
26
- pass
27
-
28
- # If no printing chars
29
- if not string :
30
- if isinstance (seq , list ):
31
- string = '' .join (map (str , seq ))
32
- # Some UserComment lists only contain null bytes, nothing valuable to return
33
- if set (string ) == {'0' }:
34
- return ''
35
- else :
36
- string = str (seq )
19
+ string = '' . join ( map ( chr , seq ))
20
+ # for char in seq:
21
+ # # Screen out non-printing characters
22
+ # try:
23
+ # if 32 <= char < 256:
24
+ # string += chr(char)
25
+ # except TypeError:
26
+ # pass
27
+
28
+ # # If no printing chars
29
+ # if not string:
30
+ # if isinstance(seq, list):
31
+ # string = ''.join(map(str, seq))
32
+ # # Some UserComment lists only contain null bytes, nothing valuable to return
33
+ # if set(string) == {'0'}:
34
+ # return ''
35
+ # else:
36
+ # string = str(seq)
37
37
38
38
# Clean undesirable characters on any end
39
- return string . strip ( ' \x00 ' )
39
+ return string
40
40
41
41
42
42
def make_string_uc (seq ) -> str :
@@ -46,7 +46,7 @@ def make_string_uc(seq) -> str:
46
46
"""
47
47
if not isinstance (seq , str ):
48
48
# Remove code from sequence only if it is valid
49
- if make_string (seq [:8 ]).upper () in ('ASCII' , 'UNICODE' , 'JIS' , '' ):
49
+ if make_string (seq [:8 ]).upper () in ('ASCII\0 \0 \0 ' , 'UNICODE\0 ' , 'JIS\0 \0 \0 \0 \0 ' , '' ):
50
50
seq = seq [8 :]
51
51
# Of course, this is only correct if ASCII, and the standard explicitly
52
52
# allows JIS and Unicode.
0 commit comments