Fixed missing zero terminating for strings, fixed conversion using UnicodeToUtf8, unicode2ascii
-
Fixed conversion of string constants when using
unicode2ascii
,Utf8ToUnicode
,UnicodeToUtf8
.
TheUnicodeToUtf8
function writes0
to the end of the string, and memory must be allocated for this0
.
TheUtf8ToUnicode
function does not write0
to the end of the string, but, likeUnicodeToUtf8
, it returns+1
to the length of the resulting string.
Theunicode2ascii
function does not write0
to the end of the string, it returns the length of the string without the terminating0
. -
In
tstringconstnode
, set thelen
after convertingascii2unicode
.
len
is used intcgstringconstnode.pass_generate_code
as the HashTable key length,
used inppuwrite
for the Attribute constructor parameter value. -
Fixed a potential bug in the scanner when reading a string constant expression.
Thes: string
argument is of typeshortstring
, i.e. s is not zero-terminated. -
In
TElfObjInput.ReadObjData
also needs to terminate the strings shstrtab, strtab with zero.
Judging by thestring(PChar(@shstrtab[shdr.sh_name]))
code, the terminating zero is needed. -
Fixed conversion from UTF16 to UTF8 in the
TStringConstNode.XMLPrintNodeData
method.
The number of UTF8 bytes can be greater than the length of the UTF16 string.
Also at the same time
- Fixed using
UnicodeToUtf8
infpwidestring
unit (issue #39746) - Fixed using
UnicodeToUtf8
in android/cwstring.pp, nativent/sysutils.pp
Resolves #39746