All Products
Search
Document Center

MaxCompute:CHR

Last Updated:Jul 21, 2023

Converts a specified ASCII code into characters.

Syntax

string chr(bigint <ascii>)

Parameters

ascii: required. An ASCII code of the BIGINT type. Valid values: 0 to 128. If the input value is of the STRING, DOUBLE, or DECIMAL type, the value is implicitly converted into a value of the BIGINT type before calculation.

Return value

A value of the STRING type is returned. The return value varies based on the following rules:

  • If the value of ascii is not within the valid range, an error is returned.

  • If the value of ascii is not of the BIGINT, STRING, DOUBLE, or DECIMAL type, an error is returned.

  • If the value of ascii is null, null is returned.

Examples

  • Example 1: Convert the ASCII code 100 into characters. Sample statement:

    -- The return value is d. 
    select chr(100);
  • Example 2: An input parameter is set to null. Sample statement:

    -- The return value is null. 
    select chr(null);
  • Example 3: The input value is a character of the STRING type. Sample statement:

    -- The input value is implicitly converted into a value of the BIGINT type before calculation. The return value is d. 
    select chr('100');

Related functions

CHR is a string function. For more information about functions related to string searches and conversion, see String functions.