Home > Back-end >  What's the proper way to write hex literal values in Delphi?
What's the proper way to write hex literal values in Delphi?

Time:11-16

In Python I can use string hex literal like "ab\xa1\x31_\x44\xf1\x10". Does Delphi has a similar syntax? I want to define a string that has this literal as initial value. I searched the document but didn't find anything related (The document is not easy to use).

CodePudding user response:

You need to prefix the hex value of a character with #$, where # is the prefix for a character value and $ the prefix for hex.

The string above can be written like:

myString := 'ab'#$a1#$31'_'#$44#$f1#$10;
  • Related