Firebird Documentation IndexFirebird 2.5 Language Ref. UpdateMiscellaneous language elements → Hexadecimal notation for “binary” strings
Firebird Home Firebird Home Prev: Hexadecimal notation for numeralsFirebird Documentation IndexUp: Miscellaneous language elementsNext: Shorthand datetime casts

Hexadecimal notation for binary strings

Available in: DSQL, PSQL

Added in: 2.5

Description: In Firebird 2.5 and up, string literals can be entered in hexadecimal notation. Each pair of hex digits defines a byte in the string. Strings entered this way will have character set OCTETS by default, but you can force the engine to interpret them otherwise with the introducer syntax.

Syntax: 

{x|X}'<hexstring>'

<hexstring>  ::=  an even number of <hexdigit>
<hexdigit>   ::=  one of 0..9, A..F, a..f

Examples: 

select x'4E657276656E' from rdb$database
  -- returns 4E657276656E, a 6-byte 'binary' string

select _ascii x'4E657276656E' from rdb$database
  -- returns 'Nerven' (same string, now interpreted as ASCII text)

select _iso8859_1 x'53E46765' from rdb$database
  -- returns 'Säge' (4 chars, 4 bytes)

select _utf8 x'53C3A46765' from rdb$database
  -- returns 'Säge' (4 chars, 5 bytes)

Notes: 

Prev: Hexadecimal notation for numeralsFirebird Documentation IndexUp: Miscellaneous language elementsNext: Shorthand datetime casts
Firebird Documentation IndexFirebird 2.5 Language Ref. UpdateMiscellaneous language elements → Hexadecimal notation for “binary” strings