[Lazarus] TStrings, Windows and Unicode

Marcos Douglas md at delfire.net
Wed Oct 24 15:37:53 CEST 2012


On Wed, Oct 24, 2012 at 10:27 AM, Howard Page-Clark <hdpc at talktalk.net> wrote:
> On 24/10/12 12:40, Marcos Douglas wrote:
>
>>> Nope.
>>> A stringlist is not LCL and it does not expect anything but strings.
>>
>>
>> I agree...
>>
>>> If you write the contents of a stringlist to a file you get bytes you
>>> have
>>> put into the list. Nothing more nothing less.
>>
>>
>> Yes, but...
>>
>>> If you want a UTF8 text file written, make sure you put UTF8 in it.
>>> Same for reading.
>>> When using filenames, you need to convert the name using the LCL function
>>> LCLtoSys (or something like that)
>>
>>
>> ...in my example I didn't do that and worked, why?
>
>
> Because you added a UTF8 string to a stringlist. It was saved as UTF8 bytes
> (as Marc pointed out) and when later retrieved via a stringlist LoadFromFile
> call those bytes will be inserted into the stringlist just as they were
> saved, ready to display in UTF8 encoding.

I had not explained very well. When I said the file is Ok I mean the
file on Windows Explorer, not in LCL.
Do the test and you see.

Marcos Douglas




More information about the Lazarus mailing list