Open In App

PostgreSQL – ASCII Function

The PostgreSQL ASCII() function is used to derive an ASCII (American Standard Code for Information Interchange) character. In the case of UTF-8, the ASCII() function returns the Unicode code point of the character.

Syntax:ASCII(char)

Let’s analyze the above syntax:



Example 1:

The following statement uses the ASCII() function to get the ASCII code values of character A and a:



SELECT
ASCII( 'Geeks' ),
ASCII( 'G' );

Output:

Example 2:

The below statement uses the ASCII() function to get the Unicode code point of a UTF-8 character:

SELECT
ASCII( '?' );

Output:

Article Tags :