To answer your question about what the code is actually doing, this statement:
result := result + myUnicodeString;
Does the following:
calls
System._UStrFromWStr()
to convertResult
to a tempUnicodeString
calls
System._UStrCat()
to concatenatemyUnicodeString
onto the tempcalls
System._WStrFromUStr()
to convert the temp to aWideString
and assign it back toResult
.
There is a System._WStrCat()
function for concatenating a WideString
onto a WideString
(and System._UStrCat()
for UnicodeString
). If CodeGear/Embarcadero had been smarter about it, they could have implemented a System._WStrCat()
overload that takes a UnicodeString
as input and a WideString
as output (and vice versa for concatenating a WideString
onto a UnicodeString
). That way, no temp UnicodeString
conversions would be needed anymore. Both WideString
and UnicodeString
are encoded as UTF-16 (well mostly, but I won't get into that here), so concatenating them together is just a matter of a single allocation and move, just like when concatenating two UnicodeString
s or two WideString
s together.