HEXBYT: Converting a Decimal Integer to a Character

How to:

Available Languages: reporting, Maintain

The HEXBYT function obtains the ASCII, EBCDIC, or Unicode character equivalent of a decimal integer, depending on your configuration and operating environment. It returns a single alphanumeric character in the ASCII, EBCDIC, or Unicode character set. You can use this function to produce characters that are not on your keyboard, similar to the CTRAN function.

In Unicode configurations, this function uses values in the range:

The display of special characters depends on your software and hardware; not all special characters may appear. For printable ASCII and EBCDIC characters and their integer equivalents see the Character Chart for ASCII and EBCDIC.


Top of page

x
Syntax: How to Convert a Decimal Integer to a Character
HEXBYT(decimal_value, output)

where:

decimal_value

Integer

Is the decimal integer to be converted to a single character. In non-Unicode environments, a value greater than 255 is treated as the remainder of decimal_value divided by 256.

output

Alphanumeric

Is the name of the field that contains the result, or the format of the output value enclosed in single quotation marks.



Example: Converting a Decimal Integer to a Character

HEXBYT converts LAST_INIT_CODE to its character equivalent and stores the result in LAST_INIT:

TABLE FILE EMPLOYEE
PRINT LAST_NAME AND
COMPUTE LAST_INIT_CODE/I3 = BYTVAL(LAST_NAME, 'I3');
COMPUTE LAST_INIT/A1 = HEXBYT(LAST_INIT_CODE, LAST_INIT);
WHERE DEPARTMENT EQ 'MIS';
END

The output for an ASCII platform is:

LAST_NAME LAST_INIT_CODE LAST_INIT 
--------- -------------- --------- 
SMITH                 83 S 
JONES                 74 J 
MCCOY                 77 M 
BLACKWOOD             66 B 
GREENSPAN             71 G 
CROSS                 67 C

The output for an EBCDIC platform is:

LAST_NAME LAST_INIT_CODE LAST_INIT 
--------- -------------- --------- 
SMITH                226 S 
JONES                209 J 
MCCOY                212 M 
BLACKWOOD            194 B 
GREENSPAN            199 G 
CROSS                195 C

WebFOCUS