Types ShortString, AnsiChar and AnsiString in Delphi Tokyo for Linux

1

In Delphi Tokyo for Linux, what are the equivalent types of:

  • ShortString
  • AnsiChar
  • AnsiString

I send this block of code to show how these types work for Windows but for Linux not:

     program Project1;

{$APPTYPE CONSOLE}

{$R *.res}

uses
  System.SysUtils;

Var
  Ch1   : Char;
  SStr1 : String;
  AStr1 : String;
{$IFNDEF LINUX}
  Ch2   : AnsiChar;
  SStr2 : ShortString;
  AStr2 : AnsiString;
{$ENDIF}
  Ch3   : UTF8Char;
  SStr3 : String;
  AStr3 : UTF8String;
begin
  try
    { TODO -oUser -cConsole Main : Insert code here }
    Ch1:= 'A'; SStr1:='AaBbCcD'; AStr1:='1234567';
    WriteLn('"',Ch1,'"-"',SStr1,'"-"',AStr1,'"');
{$IFNDEF LINUX}
    Ch2:= 'A'; SStr2:='AaBbCcD'; AStr2:='1234567';
    WriteLn('"',Ch2,'"-"',SStr2,'"-"',AStr2,'"');
{$ELSE}
    WriteLn('En Delphi Linux no se cuenta con los tipos Ansichar, ShortString y AnsiString');
    WriteLn('Cuáles son los tipos equivalentes?');
{$ENDIF}
    Ch3:= 'A'; SStr3:='AaBbCcD'; AStr3:='1234567';
    WriteLn('"',Ch3,'"-"',SStr3,'"-"',AStr3,'"');
    ReadLn;
  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;
end.
    
asked by GBM 07.09.2018 в 18:10
source

1 answer

0

There are no really equivalent types to ShortString , AnsiChar or AnsiString , among others, in the compiler known as NextGen , which is the compiler that is used for mobile platforms and Linux .

According to the document Migrating Delphi Code to Mobile from Desktop , the possible substitutes could be:

  • System.AnsiString , System.ShortString : Completely eliminate its use, consider array of byte (I add TBytes )
  • System.AnsiChar : System.Char , System.Byte , System.UInt8

When talking about substitutes here, we are talking about types of data that could contain the same information, but that will have some variation in the way to process it, or to store it.

    
answered by 12.09.2018 в 17:42