The end of the string is marked by the character 0, so that character must never be part of a Wstring or the content will be truncated.
From this it wasn't clear to me that in fact the character 0 is part of the Wstring and one has to use Wstring*(cnt+1) if the
string to be stored has length cnt.
It would be nice to find this hint in the documentation.
I wonder why the FB developers didn't provide a dynamic WString facility, like String. Then they could have had a wzstring type that behaved just like zstring, but with unicode, requiring the extra byte, and fixed allocation. Seems a bit confusing at first blush, since WString is likely to be more used than String in future years.
PaulSquires wrote:A dynamic WSTRING string type is on the top of my wish list as well. Would make COM programming in Windows much easier.
A two byte string type is not automatically a COM BSTR. Heavy use of COM BSTRs is slowing because it goes via the COM memory manager, e.g. Delphi has both a COM and non COM WCHAR based string typed