[fpc-pascal] Best way to insert bytes into a TBytes variable?

Sven Barth pascaldragon at googlemail.com
Sun Jul 30 09:33:59 CEST 2017


Am 30.07.2017 08:07 schrieb "Bo Berglund" <bo.berglund at gmail.com>:
>
> On Fri, 28 Jul 2017 16:35:05 +0200, Michael Schnell
> <mschnell at lumino.de> wrote:
>
> >On 25.07.2017 10:54, Bo Berglund wrote:
> >>   so I need to write efficient replacements for certain string
functions (Delete, Insert, Copy etc).
> >Why do you think the string function (if using strictly just a single
> >UTF-8 or RawByte branded String type) are not efficient ?
> >
> >If all string encoding brands in an operation are the same there will be
> >no conversion.
>
> Sorry,
> I was not clear in my question...
>
> What I meant to say is that I need to convert an existing application
> that uses strings (AnsiString) as binary data buffers to instead use
> TBytes buffers. Thus my quest is for functions operating like the
> convenient string functions but on TBytes arrays.
>
> All of this is because I have found that using AnsiString is
> triggering data changes when the application is running in certain
> countries (locales) and processing certain data values...
>
> 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.

Just declare a type alias so that you can keep it compatible with older
Delphi versions as well.

Regards,
Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20170730/357ab7c5/attachment.html>


More information about the fpc-pascal mailing list