UNICODE function
The UNICODE function in Excel is used to return the Unicode code point (numeric value) of the first character in a given text string. This is useful for determining the numerical representation of characters, especially for special symbols, non-English characters, or emojis.
Syntax:
=UNICODE(text)
Parameters:
- text (required): The text string from which you want to extract the Unicode value of the first character. It can be a text string or a cell reference containing the text.
Key Points:
- The
UNICODEfunction returns a number that corresponds to the Unicode value of the first character in the given text string. - It only considers the first character; if there are multiple characters, the function will only return the Unicode value of the first one.
- This function is helpful when you want to identify or work with non-printable characters or special characters that are represented by specific Unicode values.
Examples of Usage:
1. Getting the Unicode Value of a Regular Character
If cell A1 contains the letter "A", you can get its Unicode value:
=UNICODE(A1)
This will return:
65
Explanation:
- The Unicode value of the letter
"A"is65.
2. Getting the Unicode Value of an Emoji
If cell B1 contains the emoji "😊", you can get its Unicode value:
=UNICODE(B1)
This will return:
128522
Explanation:
- The Unicode value of the smiling face emoji
"😊"is128522.
3. Getting the Unicode Value of a Special Character
If cell C1 contains the heart symbol "❤️", you can get its Unicode value:
=UNICODE(C1)
This will return:
10084
Explanation:
- The Unicode value of the heart symbol
"❤️"is10084.
4. Getting the Unicode Value of a Non-English Character
If cell D1 contains the character "ñ", you can get its Unicode value:
=UNICODE(D1)
This will return:
F1
Explanation:
- The Unicode value of
"ñ"is0xF1(241 in decimal).
Notes:
- Returns the Unicode Value of Only the First Character: If the text contains more than one character,
UNICODEwill only return the value for the first character. For example,UNICODE("abc")will return97(the Unicode value for"a"), not for"b"or"c". - Non-ASCII Characters: This function is especially useful for characters outside the basic ASCII range, such as characters from other languages, mathematical symbols, or emojis.
- Limitations: The
UNICODEfunction only returns the Unicode code point for the first character of the text string. If you need the Unicode values for other characters, you must use additional formulas or functions.
Related Functions:
UNICHAR: This is the inverse of theUNICODEfunction. It takes a Unicode value (a number) and returns the corresponding character. For example,UNICHAR(65)will return"A".CHAR: Returns the character based on a given ASCII value, but only works for values in the range of 0–255. For Unicode characters,UNICODEandUNICHARare preferred.
The UNICODE function is essential for understanding and working with text in different languages, symbols, and emojis, and it helps in analyzing or processing characters based on their Unicode representation.