@@ -16,27 +16,27 @@ def make_string(seq: Union[bytes, list]) -> str:
1616 """
1717 Don't throw an exception when given an out of range character.
1818 """
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)
3737
3838 # Clean undesirable characters on any end
39- return string . strip ( ' \x00 ' )
39+ return string
4040
4141
4242def make_string_uc (seq ) -> str :
@@ -46,7 +46,7 @@ def make_string_uc(seq) -> str:
4646 """
4747 if not isinstance (seq , str ):
4848 # 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 ' , '' ):
5050 seq = seq [8 :]
5151 # Of course, this is only correct if ASCII, and the standard explicitly
5252 # allows JIS and Unicode.
0 commit comments