The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 4,177 other subscribers

Valid reasons for having Delphi AnsiString on Mobile platform…not only for Internet but for Shaders also. //…

Posted by jpluimers on 2017/12/27

It’s too bad that you need workarounds to get ByteStrings working on mobile devices as there are APIs there (like shaders) that work best with them.

There was a nice discussion on this last year at [WayBack] I miss AnsiString on Mobile…not only for Internet but for Shaders also.// FMX.Context.GLES.pasconstGLESHeaderHigh: array [0..24] of byte =(Byte(‘p), … – Paul TOTH – Google+ based in this code example in the FMX library undocumented unit FMX.Context.GLES:

// FMX.Context.GLES.pas

  GLESHeaderHigh: array [0..24] of byte =
    (Byte('p'), Byte('r'), Byte('e'), Byte('c'), Byte('i'), Byte('s'), Byte('i'), Byte('o'), Byte('n'), Byte(' '),
     Byte('h'), Byte('i'), Byte('g'), Byte('h'), Byte('p'), Byte(' '), Byte(' '), Byte(' '), Byte('f'), Byte('l'),
     Byte('o'), Byte('a'), Byte('t'), Byte(';'), Byte(#13));

There are more than 500 places in the Delphi library sources that uses this construct and even more that do other fiddling (like [WayBackTEncoding.GetBytes) to get from strings to bytes.

I wonder if by now we still need the workarounds that Andreas Hausladen provides:


6 Responses to “Valid reasons for having Delphi AnsiString on Mobile platform…not only for Internet but for Shaders also. //…”

  1. rvelthuis said

    You do know, I hope, that the recent versions of Delphi do actually support UTF8String and RawByteString on mobile platforms too? And even the older versions do accept 8-byte string constants, and allow you to use the MarshaledAString type. So that FMX constant was simply made out of ignorance aboutcurrent Delphi. The programmer was not well known with Delphi yet, otherwise this

    for I := 0 to High(GLESHeaderHigh) do
      code[I] := GLESHeaderHigh[I];

    would have been replaced by a simple Move(), etc.

  2. Kazantsev Alexey said

    We can use MarshaledAString:

    // declaration
    Signature = ‘magic signature’#13;


    // using. compiler’s magic does typecast without overhead
    move(MarshaledAString(Signature)^, …someDestination… , Length(Signature));

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: