Excel Function: UNICODE
Purpose
The UNICODE function translates the first character in a text value into the number that it corresponds to in the unicode system.
Invocations of the UNICODE function take the form:
UNICODE(text)
Arguments
Argument | Argument type | Description |
---|
text | Mandatory | A text value whose first character will be examined and its unicode number returned. |
Related Functions
Function | Example | Purpose |
---|
UNICHAR | UNICODE(UNICHAR(number)) | Returns the character corresponding to a unicode number. |
Error Conditions
Error value | Condition type | Condition |
---|
#VALUE! | Bad argument | A value of type currency, geography, or stock was supplied to the text argument. |
Examples
Example | Formula | Result | Description |
---|
1 | =UNICODE("a") | 97 | Applying the UNICODE function to a single character returns its unicode number. |
2 | =UNICODE("ab") | 97 | Applying the UNICODE function to text returns the unicode number of the first character. |
3 | =UNICODE(DATE(2023,5,7)) | 52 | The date May 7, 2023 is stored as 45053. The unicode number of “4” was returned. |
4 | =UNICODE(TIME(12,00,00)) | 48 | The time 12:00:00 is stored as 0.5. The unicode number of “0” was returned. |
5 | =UNICODE(1) | 49 | Applying the UNICODE function to a single digit number returns its unicode number. |
6 | =UNICODE(12) | 49 | Applying the UNICODE function to a number returns the unicode number of its first digit. |
Examples: Errors
Example | ‘Text’ argument | Result | Description |
---|
1 | MICROSOFT CORPORATION (XNAS:MSFT) | #VALUE! | Supplying a stock value to the UNICODE function’s text argument causes an error. |
2 | USD/EUR | #VALUE! | Supplying a currency value to the UNICODE function’s text argument causes an error. |
3 | Stamford | #VALUE! | Supplying a geography value to the UNICODE function’s text argument causes an error. |
These errors can be mitigated by converting values of type stock, currency and geography to text before passing them to the UNICODE function. I.e.:
UNICODE(VALUETOTEXT(text,0))