Skip to main content

unhex (Function)

Returns a string by converting the hexadecimal characters in the input string.

Syntax

<STRING> str:unhex(<STRING> input.string)

Query Parameters

NameDescriptionDefault ValuePossible Data TypesOptionalDynamic
input.stringThe hexadecimal input string that needs to be converted to string.STRINGNoYes

Example 1

@info(name = 'unhexExample')
SELECT str:unhex('4d7953514c') AS unhexedText;

The unhexExample demonstrates the use of the str:unhex() function, which converts a hexadecimal value into a string. In this example, the input hexadecimal value is '4d7953514c'. After applying the unhex() function, the resulting output is 'MySQL'.

Example 2

CREATE STREAM InputStream (eventTime long, hexValue string);

CREATE SINK STREAM OutputStream (eventTime long, unhexedText string);

@info(name = 'unhexStreamWorker')
INSERT INTO OutputStream
SELECT eventTime, str:unhex(hexValue) AS unhexedText
FROM InputStream;

The unhexStreamWorker processes events from the InputStream and applies the str:unhex() function to the hexValue attribute, converting the hexadecimal value to a string. The query outputs the eventTime and the converted hexValue as unhexedText for each event to the OutputStream.