UFMT: Converting an Alphanumeric String to Hexadecimal

How to:

Available Languages: reporting, Maintain

The UFMT function converts characters in an alphanumeric source string to their hexadecimal representation. This function is useful for examining data of unknown format. As long as you know the length of the data, you can examine its content.

Syntax: How to Convert an Alphanumeric String to Hexadecimal

UFMT(source_string, length, output)

where:

source_string

Alphanumeric

Is the alphanumeric string to convert enclosed in single quotation marks ('), or the field that contains the string.

length

Integer

Is the number of characters in source_string.

output

Alphanumeric

Is the name of the field that contains the result, or the format of the output value enclosed in single quotation marks ('). The format of output must be alphanumeric and its length must be twice that of length.

Example: Converting an Alphanumeric String to Hexadecimal

UFMT converts each value in JOBCODE to its hexadecimal representation and stores the result in HEXCODE:

DEFINE FILE JOBFILE
HEXCODE/A6 = UFMT(JOBCODE, 3, HEXCODE);
END
TABLE FILE JOBFILE
PRINT JOBCODE HEXCODE
END

The output is:

JOBCODE  HEXCODE 
-------  ------- 
A01      C1F0F1 
A02      C1F0F2 
A07      C1F0F7 
A12      C1F1F2 
A14      C1F1F4 
A15      C1F1F5 
A16      C1F1F6 
A17      C1F1F7 
B01      C2F0F1 
B02      C2F0F2 
B03      C2F0F3 
B04      C2F0F4 
B14      C2F1F4