[fpc-devel] new string - question on usage
Sven Barth
pascaldragon at googlemail.com
Wed Oct 12 09:58:19 CEST 2011
Am 11.10.2011 23:09, schrieb Hans-Peter Diettrich:
> Marco van de Voort schrieb:
>
>> Note that many places that are runtime typed (like
>> tstringlist.loadfromfile)
>> get a encoding parameter, so that the loading code can convert the
>> encoding
>> of the file (in encoding parameter) to whatever stringtype tstringlist
>> uses
>> (typically utf8 or utf16 or "default")
>
> Do you refer to the Delphi or FPC implementation? I couldn't find yet an
> encoding in FPC TStrings or TStringList.
As our codepage aware string implementation is only at the beginning and
thus no changes to Classes, etc were done yet, I'd say that he's
speaking about the Delphi implementation (though FPC might follow here
later on).
>> In short, see it as if text now has a mandatory encoding attached. If the
>> runtime doesn't know the type, then it is not text, but binary, and you
>> should treat it as such.
>
> Can you give an example, how the runtime can not know the type of an
> string?
If you just opened a file (no reading done yet) you don't know the
encoding. Or if the file has no BOM then you might want to guess the
encoding based on the content read. As long as you haven't guessed the
encoding (no matter whether the guess is right or wrong) you don't know
the encoding.
Regards,
Sven
More information about the fpc-devel
mailing list