The CODE function returns the code of the first character in a string based on the system language and the encoding used on the device.
This can be useful when you need to find out the code of a specific character in the ASCII or Unicode table.
Syntax
CODE(string)
Argument |
Description |
Permitted values |
|---|---|---|
string |
Text in which you need to find out the code of the first character |
A single character, string, or reference to a cell containing a string |
Examples of use
Retrieving a code for a single character
=CODE("A")
The function will return 65, as this is the code for the character “A” in the ASCII table.
Retrieving the code for the space character
=CODE(" ")
The function will return 32, which is the code for the space character.
Working with a text string
=CODE("Hello")
The function will return the code of the first character in the string, which is the code for the letter “H” (72).
Notes
If you submit a string consisting of multiple characters, the function will return the code for only the first character.