

 Amazon Redshift will no longer support the use of Python UDFs after June 30, 2026. We will start enforcing it in phases. For more information on the details of Python end of life and migration options, see the [ blog post ](https://aws.amazon.com/blogs/big-data/amazon-redshift-python-user-defined-functions-will-reach-end-of-support-after-june-30-2026/) that was published on June 30, 2025. 

# ASCII function
<a name="r_ASCII"></a>

The ASCII function returns the ASCII code, or the Unicode code-point, of the first character in the string that you specify. The function returns `0` if the string is empty. It returns `NULL` if the string is null. 

## Syntax
<a name="r_ASCII-synopsis"></a>

```
ASCII('string')
```

## Argument
<a name="r_ASCII-arguments"></a>

 *string*   
A `CHAR` string or a `VARCHAR` string. 

## Return type
<a name="r_ASCII-return-type"></a>

 INTEGER 

## Examples
<a name="r_ASCII-examples"></a>

To return `NULL`, use the following example. The NULLIF function returns `NULL` if the two arguments are the same, so the input argument for the ASCII function is `NULL`. For more information, see [NULLIF function](r_NULLIF_function.md).

```
SELECT ASCII(NULLIF('',''));

+-------+
| ascii |
+-------+
|  NULL |
+-------+
```

To return the ASCII code 0, use the following example. 

```
SELECT ASCII('');

+-------+
| ascii |
+-------+
|     0 |
+-------+
```

To return the ASCII code 97 for the first letter of the word amazon, use the following example. 

```
SELECT ASCII('amazon');

+-------+
| ascii |
+-------+
|    97 |
+-------+
```

To return the ASCII code 65 for the first letter of the word Amazon, use the following example.

```
SELECT ASCII('Amazon');

+-------+
| ascii |
+-------+
|    65 |
+-------+
```