ascii_char

<< addYear | FB 2.0 Language Reference | dow >>

ascii_char

Library: ib_udf

Changed in: 1.0, 2.0

Description

Returns the ASCII character corresponding to the integer value passed in.

Result type: VARCHAR(1)

Syntax (unchanged)

 ascii_char (intval)

Declaration

 DECLARE EXTERNAL FUNCTION ascii_char
   INTEGER NULL
   RETURNS CSTRING(1) FREE_IT
   ENTRY_POINT 'IB_UDF_ascii_char' MODULE_NAME 'ib_udf'

The declaration reflects the fact that the UDF as such returns a 1-character C string, not an SQL CHAR(1) as stated in the InterBase declaration. The engine will pass the result to the caller as a VARCHAR(1) though.

The NULL after INTEGER is an optional addition that became available in Firebird 2. When declared with the NULL keyword, the engine will pass a NULL argument unchanged to the function. This causes a NULL result, which is correct. Without the NULL keyword (your only option in pre-2.0 versions), NULL is passed to the function as 0 and the result is an empty string.

For more information about passing NULLs to UDFs, see the note at the end of this book.

Notes

  • ascii_char(0) returns an empty string in all versions, not a character with ASCII value 0.
  • Before Firebird 2.0, the result type was CHAR(1).

back to top of page
<< addYear | FB 2.0 Language Reference | dow >>