[Lazarus] String vs WideString
Michael Schnell
mschnell at lumino.de
Tue Aug 15 12:34:45 CEST 2017
On 15.08.2017 12:11, Mattias Gaertner via Lazarus wrote:
> It does not explain what the characters of DynamicString are, does it?
I don't understand what you are asking.
The element size and encoding of a Dynamic String ("CP_ANY" in the
document) are not predefined, but depend on the content:
http://wiki.freepascal.org/not_Delphi_compatible_enhancement_for_Unicode_Support
-> Defining String variables and String types:
> *CP_ANY* = $FF00 // ElementSize dynamically assigned // fully
> dynamical String for intermediate storing string content // just
> assigned to the Type or variable, never used in the "Encoding" field
> in the string header.
Hence it stores the "branding" when it is assigned to from a string with
a fixed branding (such as *CP_UTF8*), and the content is auto-converted
if necessary when assigning form CP_ANY to a fixed branded string variable.
If (in your example) the data is read from a file, a CP_ANY Strings
based StringList would keep the encoding/char_size of the data as t is
in the file (it would need to somehow get to know the presumed encoding
of the file, anyway) and store that information in the
EncodingBrandNumber and ElementSize fields (which do exist in any
"NewString" variable, anyway), in each String read.
If the user assignes an element of the stringlist to a fixed branding
(such as *CP_UTF8*), the content obviously is auto-converted if
necessary when assigning form CP_ANY to a fixed branded string
variable, as usual.
In fact I suppose that the current implementation of TStringlist does
not use new strings to store the data on the heap, but I never said that
trying to implement such idea would not require a lot of work.
-Michael
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20170815/31b153f1/attachment.html>
More information about the Lazarus
mailing list