[Lazarus] String vs WideString

Juha Manninen juha.manninen62 at gmail.com
Sun Aug 13 13:18:23 CEST 2017


On Sun, Aug 13, 2017 at 1:21 AM, Bo Berglund via Lazarus
<lazarus at lists.lazarus-ide.org> wrote:
> I recently had a problem with an application that was converted from
> old string type to AnsiString and seemingly worked in the new Unicode
> environment.

What was the old string type?

> However, we received reports that it had failed in some Asian
> countries (Korea, China, Thailand) and upon checking it turned out
> that the data inside a string used as buffer was changed because of
> locale differences....

Unicode was designed to solve exactly the problems caused by locale differences.
Why don't you use it?

> After switching out the affected variable declarations from AnsiString
> to RawByteString the application seemingly started to work again also
> on these locations.
> ...
> And after this I have spent some time to totally rework the use of
> strings as buffers to instead use TBytes. Lots of work but
> guaranteed to not sneak in unexpected conversions.

RawByteString is for text which encoding is not meant to be converted.
It has its special use cases.
TBytes is usually for binary data.
Did I understand right: you use TBytes to hold strings having Windows
codepage encoding?
That sounds like a very dummy thing to do!
Again: Why not Unicode? Then you could throw away your hacks.

Juha


More information about the Lazarus mailing list