[Lazarus] String vs WideString

Bo Berglund bo.berglund at gmail.com
Sun Aug 13 11:19:35 CEST 2017


On Sat, 12 Aug 2017 23:42:43 -0300, "Marcos Douglas B. Santos via
Lazarus" <lazarus at lists.lazarus-ide.org> wrote:

>> After switching out the affected variable declarations from AnsiString
>> to RawByteString the application seemingly started to work again also
>> on these locations.
>>
>> So AnsiString is not safe either....
>>
>> 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.
>
>Is not simpler to use RawByteString instead TBytes?

Well, initially just changing the declarations would seem to be
simpler. But given how the conversion problem sneaked up behind my
back, I thought it wiser to move all serial comm buffers from various
string types (string->AnsiString->RawByteString) to TBytes since that
is really guaranteed to be "the real thing".

Whenever there is a need for displaying the data or putting them into
a string type variable I have added a few utility functions to do the
conversions using the Move() procedure. Likewise I made a PosBin() for
searching for patterns like Pos() for strings etc.


-- 
Bo Berglund
Developer in Sweden



More information about the Lazarus mailing list