[fpc-pascal] Best way to insert bytes into a TBytes variable?
pascaldragon at googlemail.com
Sun Jul 30 16:12:11 CEST 2017
Am 30.07.2017 12:37 schrieb "Bo Berglund" <bo.berglund at gmail.com>:
> 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.
Not a fixed codepage for the application, but a string with fixed codepage,
e.g. "String(CP_1242)" or so...
> The root problem is what happens with string conversions on different
> locales and some functions could not be easily modified to use
> 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:
> TMyString = RawByteString;
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the fpc-pascal