String types

Top  Previous  Next

User interface > Translation options > Type options > String types

 

At the type options you can chose how the string types AnsiString, WideString and String are translated.

 

 

Options_StringType

 

 

If Delphi string is selected, the translated code will use classes for AnsiString, WideString and UnicodeString. In C++Builder these classes are provided. If you chose this option for other compilers, you have to create these classes yourself. They have to be 1 based and have to obey the specifications from Embarcadero:

 

http://docwiki.embarcadero.com/RADStudio/Tokyo/en/String_Types_(Delphi)

 

 

 

If Standard string is selected, the following typedef's are needed:

 

 

typedef std::string  AnsiString

typedef std::wstring WideString

typedef std::wstring UnicodeString

 

 

Delphi functions for strings will be converted to  functions for AnsiString/UnicodeString or std::string/std::wstring. Examples:

 

 

var

  s1, s2 : String;

begin

  Length(s1);            

  SetLength(s1, 10);      

  s1 := '12345678';

  s2 := copy(s1, 3, 4); 

  Delete(s1, 3, 2);      

  Pos(s1, s2);      

 

->

 

  Delphi string                       Standard string

 

  s1.Length();                        s1.size();           

  s1.SetLength(10);                   s1.resize(10);         

  s1 = L"12345678";                   s1 = L"12345678";      

  s2 = s1.SubString(3, 4);            s2 = s1.substr(3-1, 4);

  s1.Delete(3,  2);                   s1.erase(3-1,  2);     

  s2.Pos(s1);                         s2.find(s1);           

 

 

 

 

d2c string is an experimental own AnsiString/UnicodeString based on std::string/std::wstring

 

 

 

According to the chosen "String" as option String will be treated either as AnsiString or as UnicodeString.

 

var

S: String:

begin

S := 'hallo';

 

is translated for an Ansi association to:

 

String S;

S = "hallo";

 

and for the Unicode association to

 

String S;

S = L"hallo";

 

 

 

 

 



This page belongs to the Delphi2Cpp Documentation

Delphi2Cpp home  Content