mirror of
https://github.com/Sei-Lisa/LSL-PyOptimizer
synced 2025-07-01 23:58:20 +00:00
Err when invalid UTF-8 should have been generated in LSO mode.
LSO strings are byte arrays, but our strings are made for Mono which uses Unicode, and invalid UTF-8 sequences can't be stored in Unicode without using a custom representation. One possible representation is to only use the codepoints 0-255 in the Unicode string, to avoid supporting multiple types for strings. Something to study in future.
This commit is contained in:
parent
b593141f9f
commit
e8201d6956
2 changed files with 9 additions and 0 deletions
|
@ -475,6 +475,8 @@ def InternalUTF8toString(s):
|
|||
# NOTE: Without the above line, the following one hits a bug in
|
||||
# python-coverage. It IS executed but not detected.
|
||||
continue
|
||||
if LSO:
|
||||
raise ELSONotSupported("Byte strings not supported")
|
||||
ret += u'?' * len(partialchar)
|
||||
partialchar = b''
|
||||
# fall through to process current character
|
||||
|
@ -482,11 +484,15 @@ def InternalUTF8toString(s):
|
|||
partialchar = c
|
||||
pending = 1 if o < 0xE0 else 2 if o < 0xF0 else 3
|
||||
elif o >= 0x80:
|
||||
if LSO:
|
||||
raise ELSONotSupported("Byte strings not supported")
|
||||
ret += u'?'
|
||||
else:
|
||||
ret += c.decode('utf8')
|
||||
|
||||
if partialchar:
|
||||
if LSO:
|
||||
raise ELSONotSupported("Byte strings not supported")
|
||||
ret += u'?' * len(partialchar)
|
||||
|
||||
return zstr(ret)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue