Multi-line strings

Top  Previous  Next

What is translated > Assignments > Multi-line strings

A special kind of assignments are assignments of multi-line strings. Delphi supports them starting with version number 12.1, Delphi Athens The following example shows how they are translated to C++:

 

// https://docwiki.embarcadero.com/RADStudio/Athens/en/String_Types_(Delphi)

 

 const

    strML1 = '''

      The quick brown fox jumps

      over The lazy dog.

      ''';

    strHTML = '''

      <UL>

       <LI>Item 1</LI>

       <LI>Item 2</LI>

       <LI>Item 3</LI>

       <LI>Item 4</LI>

      </UL>

      ''';

    strJSON = '''

      [

        {"id" : "1", "name" : "Large"},

        {"id" : "2", "name" : "Medium"},

        {"id" : "2", "name" : "Small"}

      ]

      ''';

    strSQL= '''

      SELECT *

      FROM Customers

      WHERE Department = 'R&D'

      ORDER BY Name;

      ''';

 

->

 

// https://docwiki.embarcadero.com/RADStudio/Athens/en/String_Types_(Delphi)

 

const UnicodeString strML1 = L"The quick brown fox jumps" "\r\n"

          "over The lazy dog."

          ;

const UnicodeString strHTML = L"<UL>" "\r\n"

          " <LI>Item 1</LI>" "\r\n"

          " <LI>Item 2</LI>" "\r\n"

          " <LI>Item 3</LI>" "\r\n"

          " <LI>Item 4</LI>" "\r\n"

          "</UL>"

          ;

const UnicodeString strJSON = L"[" "\r\n"

          "  {\"id\" : \"1\", \"name\" : \"Large\"}," "\r\n"

          "  {\"id\" : \"2\", \"name\" : \"Medium\"}," "\r\n"

          "  {\"id\" : \"2\", \"name\" : \"Small\"}" "\r\n"

          "]"

          ;

const UnicodeString strSQL = L"SELECT *" "\r\n"

          "FROM Customers" "\r\n"

          "WHERE Department = 'R&D'" "\r\n"

          "ORDER BY Name;"

          ;

 

Instead of triple quotation marks (“’”), a larger odd number of quotation marks can be used, for example 5 or 7.

 

var

  s : String;

begin

  s := '''''

  some text

  and now '''

  some more text

  ''''';

 

->

 

  String s;

  s = L"some text" "\r\n"

          "and now '''" "\r\n"

          "some more text"

          ;

 

Delphi2Cpp only supports a maximum of seven quotes

 

 

 



This page belongs to the Delphi2Cpp Documentation

Delphi2Cpp home  Content