user130268
user130268

Reputation: 1361

What's the proper way to write hex literal values in Delphi?

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).

Upvotes: 1

Views: 1306

Answers (1)

Uwe Raabe
Uwe Raabe

Reputation: 47704

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;

Upvotes: 4

Related Questions