UNHEX
Converts a hexadecimal string into its raw byte representation (as a BLOB).
This function corresponds to the unhex(X, Y) function in SQLite. It interprets the input string x as a hexadecimal string and returns a BLOB containing the corresponding sequence of bytes.
The input hexadecimal string can contain any number of hex characters (
0-9,a-f,A-F).Any characters outside of this set, including spaces and punctuation, are ignored.
If the input string has an odd number of hex characters, the last character is ignored.
The optional second argument
yspecifies a string of characters to be ignored. This can be useful if the hex string is formatted with separators (e.g., ':', '-').
If the input x is NULL, the result is NULL.
Example
// SELECT unhex('4B514C697465') -> BLOB data for the string "KQLite"
val blobData = select(UNHEX(StringLiteral("4B514C697465")))
// With an ignore-character set
// SELECT unhex('4B:51:4C:69:74:65', ':') -> same as above
val blobFromFormatted = select(UNHEX(StringLiteral("4B:51:4C:69:74:65"), ":"))Return
A KQLiteColumn of type String representing the resulting BLOB. Note that while the underlying SQLite type is BLOB, the KQLite representation might be handled as a String or require specific handling for BLOBs depending on the context.
Author
MOHAMMAD AZIM ANSARI
Parameters
The column or string value containing the hexadecimal string to be converted.
An optional string containing characters to ignore within the hex string x.