Fixed missing zero terminating for strings, fixed conversion using UnicodeToUtf8, unicode2ascii
-
Fixed conversion of string constants when using
unicode2ascii,Utf8ToUnicode,UnicodeToUtf8.
TheUnicodeToUtf8function writes0to the end of the string, and memory must be allocated for this0.
TheUtf8ToUnicodefunction does not write0to the end of the string, but, likeUnicodeToUtf8, it returns+1to the length of the resulting string.
Theunicode2asciifunction does not write0to the end of the string, it returns the length of the string without the terminating0. -
In
tstringconstnode, set thelenafter convertingascii2unicode.
lenis used intcgstringconstnode.pass_generate_codeas the HashTable key length,
used inppuwritefor the Attribute constructor parameter value. -
Fixed a potential bug in the scanner when reading a string constant expression.
Thes: stringargument is of typeshortstring, i.e. s is not zero-terminated. -
In
TElfObjInput.ReadObjDataalso 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.XMLPrintNodeDatamethod.
The number of UTF8 bytes can be greater than the length of the UTF16 string.
Also at the same time
- Fixed using
UnicodeToUtf8infpwidestringunit (issue #39746) - Fixed using
UnicodeToUtf8in android/cwstring.pp, nativent/sysutils.pp
Resolves #39746