Documentation/Calc Functions/CODE/en

Function name:
CODE

Category:
Text

Summary:
Determines the code point in the current coded character set that corresponds to the first character of a given text string or number.

The CODE function is complementary to the CHAR function.

For some characters, CODE may return the same code point as the UNICODE function but for other characters the code point returned may be system-specific and different.

Syntax:
CODE(Text)

Returns:
Returns an integer in the range 0 ≤ n ≤ 255, which is the code point in the current coded character set that corresponds to the first character of the given text string or number.

Arguments:
Text is a text string (in quotation marks) or a number, or a reference to a cell containing such a string or number, the first character of which is the character whose code point is to be determined.


 * Text can be an empty string, in which case CODE returns the value 0.
 * If the first character of Text does not correspond to one of the 256 code points in the current coded character set, then CODE returns the value 63 (which is the ASCII code for a question mark).
 * If Text is a non-negative number, then CODE returns the code point corresponding to the first digit of that number. If Text is a negative number, then CODE returns the code point corresponding to the minus sign (which has an ASCII code of 45).

Additional details:
For any code point n,

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

Related LibreOffice functions:
CHAR

UNICHAR

UNICODE

ODF standard:
Section 6.20.5, part 2

Equivalent Excel functions:
CODE