Movatterモバイル変換


[0]ホーム

URL:


You don’t need a vector database - just use Postgres for everything. Read the case study on switching from Pinecone to Neon
PostgreSQL Tutorial
PostgreSQL Tutorial

PostgreSQL ASCII() Function

The PostgreSQLASCII() function returns anASCII code value of a character. In the case of UTF-8, theASCII() function returns the Unicode code point of the character.

Syntax

The following illustrates the syntax of ASCII function:

ASCII(char)

Arguments

TheASCII() function requires one argument:

1)char

Thechar argument is acharacter that you want to get the ASCII code.

If you pass a string to theASCII() function, it will return the ASCII code of the first character.

Return value

TheASCII() function returns an integer that represents the ASCII code value of the input character. In the case of a UTF-8 character, it returns an integer which is corresponding to the Unicode code point.

Examples

The following example uses theASCII() function to get the ASCII code values of the characterA anda:

SELECT    ASCII( 'A' ),    ASCII( 'a' );

The output is:

PostgreSQL ASCII function exampleIf you pass a sequence of characters to theASCII() function, you will get the ASCII code of the first character as shown in the following example:

SELECT    ASCII('ABC' );

The function returns the ASCII code of the letter A which is 65 as follows:

PostgreSQL ASCII function - string exampleThe following example illustrates how to use theASCII() function to get the Unicode code point of a UTF-8 character:

SELECT    ASCII( 'Ω' );

PostgreSQL ASCII function - unicode example

Remarks

To get the ASCII code value or Unicode code point of an integer, you use theCHR() function.

In this tutorial, you have learned how to use the PostgreSQLASCII() function to get the ASCII code or Unicode code point of a character.

Last updated on

Was this page helpful?
Thank you for your feedback!

[8]ページ先頭

©2009-2025 Movatter.jp