Hi
For a Windows application that commonly requires UTF16, I've been using Unicodestring types, and also array of widechar types. But I have to be entirely honest - I am a bit confused as to what the differences are, and when one would use one over the other?
I've read
https://wiki.freepascal.org/Character_and_string_types#UnicodeString that states "UnicodeStrings are reference counted, null-terminated arrays, but they are implemented as arrays of WideChars" and for WideChar it states "A variable of type WideChar, also referred to as UnicodeChar, is exactly 2 bytes in size and usually contains one Unicode code point (normally a character) in UTF-16 encoding."
So, if I have an array that is
var
strA : array [0..99] of widechar; // strA can not be any larger than 100 bytes, i.e. 50 characters
strB : unicodestring; // strB is unrestricted in size
begin
strA := 'HellÖ';
strB := 'HellÖ';
end;
So in this example, under what circumstances would you opt for UnicodeString over array of WideChar, and visa versa, aside from not wanting to limit the amount of data that can go into the string which of course a fixed length array does?