parseHexString() Query Function

Parses the input from hex encoded bytes, decoding the resulting bytes as a string using the selected character set. If the input fields has a prefix (other than 0x and 16#) then use regex() or replace() to remove the prefix before using parseHexString. Any non-hex characters in the input are ignored—the decoding attempts to decode all chars in the field that match 0-9 or A-F. Case is ignored.

Parameters

Name

Type

Required

Default

Description

field

string

Yes

Specifies the field containing the hex string to use as input.

charset

string

No

UTF-8

The charset to use when transforming bytes to string. Valid charsets are: (ISO-8859-1, UTF-8).

as

string

No

_parsehexstring

Name of output field.

The implied parameter is field.

Examples

Parses the string 48656c6c6f576f726c64 from the field named foo into the field text, getting the value Helloworld

humio
parseHexString(foo, as=text, charset="ISO-8859-1")

Parses the string 0x4 865 6c6c6f576f726c6420 plus F 0 9 F 9 8 8 0 from the field named hex into the field text, using UTF-8 and getting the value Helloworld đŸ˜€ where the smiley is the result of decoding the trailing digits.

humio
hex := "0x4 865 6c6c6f576f726c6420 plus F 0 9 F 9 8 8 0" | text := parseHexString(hex)