Documentation/Calc Functions/CHAR

    From The Document Foundation Wiki
    Other languages:


    Function name:

    CHAR

    Category:

    Text

    Summary:

    Determines the character that corresponds to a given code point in the current coded character set. In some cases, the character returned by CHAR may be a non-printing character that is not readily visible (for example control characters).

    The CHAR function is complementary to the CODE function.

    For some code points, CHAR may return the same character as the UNICHAR function but for other code points the character returned may be system-specific and different.

    Syntax:

    CHAR(Number)

    Returns:

    Returns the single character that corresponds to the given code point in the current coded character set.

    Arguments:

    Number is an integer in the range 0 ≤ n ≤ 255, or a reference to a cell containing such an integer, that is the code point of the character that is required.

    • If Number is non-numeric, then CHAR reports a #VALUE! error.
    • For a non-integer value of Number, CHAR truncates the value to an integer.
    • If, after any truncation, Number is less than 0 or greater than 255, then CHAR reports an invalid argument error (Err:502).

    Additional details:

    For any code point n, n = CODE(CHAR(n))

    Since the characters returned for some code points can differ between systems, spreadsheets using the CHAR function may not be portable.

    Examples:

    Formula Description Returns
    =CHAR(65) Here the function returns the uppercase A character. A
    =CHAR(D1) where cell D1 contains the number 122. Here the function returns the lowercase z character. z
    =CHAR(HEX2DEC("3B")) It is common to refer to code points in hexadecimal notation. Here the function returns the semicolon character. The code point for the semicolon is 3B in hexadecimal notation, 59 in decimal. ;
    ="abc" & CHAR(10) & "def" Here CHAR(10) returns the line feed character. On a Windows computer this formula should insert a newline between the two strings (refer to Wikipedia's Newline page for more information about how newlines are handled in various environments). abc
    def

    Related LibreOffice functions:

    CODE

    UNICHAR

    UNICODE

    ODF standard:

    Section 6.20.3, part 2

    Related (or similar) Excel functions:

    CHAR