File tree Expand file tree Collapse file tree 1 file changed +1
-14
lines changed
Expand file tree Collapse file tree 1 file changed +1
-14
lines changed Original file line number Diff line number Diff line change @@ -172,20 +172,7 @@ def format_data(
172172 throw_error (f"Expected string, got { type (data ).__name__ } " , errors = errors )
173173 if not isinstance (max_length , int ) or max_length <= 0 :
174174 throw_error (f"Invalid maximum length: { max_length } " , errors = errors )
175- ret = bytearray ()
176- for s in data :
177- c = ord (s )
178- if c > 0xFFFF :
179- throw_error (f"Character { s } (0x{ c :X} ) is not supported." , errors = errors )
180- else :
181- ret .append (c & 0xFF )
182- ret .append ((c >> 8 ) & 0xFF )
183- if len (ret ) > max_length :
184- throw_error (
185- f"Data length exceeds maximum length of { max_length } bytes: { len (ret )} bytes." ,
186- errors = errors ,
187- )
188- return bytes (ret .ljust (max_length , b"\x00 " ))[:max_length ]
175+ return data .encode ("utf-16le" ).ljust (max_length , b"\x00 " )[:max_length ]
189176
190177
191178def pkg_message (
You can’t perform that action at this time.
0 commit comments