Skip to main content

char

1. CHAR Function

The CHAR function in H2 database is used to convert an ASCII code or Unicode code point to its corresponding character.

2. Syntax

The syntax for the CHAR function in H2 database is as follows:

CHAR(code)

Arguments

  • code: The ASCII code or Unicode code point for which the character needs to be retrieved. It should be a numeric value.

Return

  • The CHAR function returns the character corresponding to the given code.

3. Notes

  • The CHAR function in H2 database supports both ASCII codes and Unicode code points. However, it is recommended to use Unicode code points for better compatibility and support for a wider range of characters.
  • If the input code is not a number or exceeds the valid code range, the CHAR function will return NULL.
  • Make sure to provide the correct code to retrieve the desired character.

4. Examples

Here are a few examples demonstrating the usage of the CHAR function in H2 database:

Example 1 - Retrieving character for ASCII code:

SELECT CHAR(65) AS character;

Output:

character
---------
A

Example 2 - Retrieving character for Unicode code point:

SELECT CHAR(9731) AS character;

Output:

character
---------

Example 3 - Retrieving characters for a range of code points:

SELECT CHAR(9786) AS smiley, CHAR(9829) AS heart, CHAR(128516) AS emoji;

Output:

smiley | heart | emoji
-------+-------+------
☺ | ♥ | 😄
  • ascii - Convert character to ASCII code
  • UNICODE - Convert character to Unicode code point