PostgreSQL chr() Function

The PostgreSQL chr() function returns the character represented by the given code.

chr() Syntax

This is the syntax of the PostgreSQL chr() function:

chr(code)

Parameters

code

Required. An integer, which can be an ASCII code value or a Unicode code point. It can’t be 0.

Return value

The PostgreSQL chr() function returns the character represented by the given code.

In UTF8 encoding, this parameter code is treated as a Unicode code point. In other multibyte encodings, arguments are treated as ASCII characters.

chr(0) is not allowed because the text data type cannot store the character.

chr() Examples

This example shows how to return a character corresponding to an ASCII value using the chr() function.

SELECT
    chr(65) AS "chr(65)",
    chr(97) AS "chr(97)";
 chr(65) | chr(97)
---------+---------
 A       | a