[fpc-pascal] Best way to insert bytes into a TBytes variable?
Bo Berglund
bo.berglund at gmail.com
Sun Jul 30 12:37:20 CEST 2017
On Sun, 30 Jul 2017 09:33:59 +0200, Sven Barth via fpc-pascal
<fpc-pascal at lists.freepascal.org> wrote:
>> The application was started back in Delphi7 times when "string"
>> actually meant AnsiString and was a 1-byte per element container.
>
>You could always use RawByteString or a string with a fixed codepage
>instead if plain AnsiString.
I asked about this problem over at Embarcadero too, but was flamed for
even thinking about using any kind of string for storing binary data.
THeyn did suggest RawByteString too, though so I went over the
application changing all buffers to RawByteString and it did work.
I also tried to set a fixed codepage for the application, but it is
hard to check if it actually does help.
The root problem is what happens with string conversions on different
locales and some functions could not be easily modified to use
RawByteString.
So I decided to bite the bullet and convert the whole unit to TBytes
instead. Some 7000 code lines to go over...
It has taken a good many hours now and I still have some intricate
problems to solve. It still won't compile without errors.
>
>Just declare a type alias so that you can keep it compatible with older
>Delphi versions as well.
>
Do you mean:
type
TMyString = RawByteString;
--
Bo Berglund
Developer in Sweden
More information about the fpc-pascal
mailing list