Description
Use this function to return the Unicode value of the first character in a text string. This is the opposite of the UNICHAR function.
Syntax
UNICODE(text)
Inputs
This function accepts the following arguments:
| Name | Required | Description | Valid input |
|---|---|---|---|
text |
Yes | The text for which you want the first character's Unicode value. | A single character that is surrounded by double quotation marks (” “) entered directly into the function, a cell reference, or a formula which results in either of these. |
Example
Sample data
| A | ||
|---|---|---|
| 1 | Apple | |
| 2 | Boat | |
| 3 | George | |
| 4 | 45 |
Sample formulas
| Use case | Formula | Explanation and Result |
|---|---|---|
| Look up the Unicode value for a specific character you type directly into the formula. | =UNICODE("A") |
Returns the numeric code point for the letter "A". Result: 65 |
| Look up the Unicode value of the first character in a cell's text. | =UNICODE(A3) |
Reads the first character of "George" ("G") and returns its code point. Result: 71 (the value for "G") |
| Look up the Unicode value of the first character when a cell holds a number instead of text. | =UNICODE(A4) |
Treats the number 45 as the text "45" and returns the code point of its first character, "4". Result: 52 (the value for "4") |
| Look up the Unicode value of the first character in a number typed directly into the formula. | =UNICODE(24) |
Treats the number 24 as the text "24" and returns the code point of its first character, "2". Result: 50 (the value for "2") |
| Look up the Unicode value of a character elsewhere in a text string, not just the first one. | =UNICODE(MID(A3,3,2)) |
Pulls "or" out of "George" starting at the 3rd character, then returns the code point of its first character, "o". Result: 111 (the value for "o") |
Notes
- The UNICODE function returns the Unicode value of the first character in a text string.
- If the text string is empty, UNICODE returns the #VALUE! error.
- The font used in a worksheet may alter the appearance of characters, especially for 'high ASCII' characters (characters numbered 128 to 255, corresponding to Unicode U+0080 to U+00FF). Different fonts may render these characters in various ways, which might affect their visual representation.
- The function can be used to identify characters in a text string that may not display correctly in certain fonts or applications.
Tips
- Use UNICODE to find the numeric code of characters, which can be useful for debugging text data issues.
- Combine UNICODE with functions such as MID and LEN to analyze and manipulate text strings more effectively.
- UNICODE returns the code point of the first character only. To get the code points of subsequent characters, use functions such as MID in conjunction with UNICODE. (See example above.)