PostgreSQL – ASCII Function
Last Updated :
08 Feb, 2024
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:
- The char argument is a character for which you want to derive the ASCII code. It is also important to note that if the user passes a string to the ASCII() function, it will return the ASCII code of the first character.
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:
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...