What's the difference between UNICODE() and CODE()?

Cubist

Well-known Member
Joined
Oct 5, 2023
Messages
1,026
Office Version
  1. 365
Platform
  1. Windows
I want to know the difference between the two functions UNICODE() and CODE(). Based on their Microsoft documentations,

UNICODE(): "This article describes the formula syntax and usage of the UNICODE function in Microsoft Excel."
CODE(): "Returns a numeric code for the first character in a text string. The returned code corresponds to the character set used by your computer."

Similarly CHAR() vs. UNICHAR(). I'm trying to understand the use case preferences between the two. Thanks.
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Upon my investigation,
UNICHAR() and CHAR() return the same for numbers 1-127.
UNICHAR() returns blanks while CHAR() returns additional characters for numbers 128-159.
UNICHAR() and CHAR() return the same for numbers 160-255.
UNICHAR() returns characters for number 256+ while CHAR() give #VALUE error.

Book1
ABC
1NumberUNICHARCHAR
21  
32
43
54
65
76
87
98
109
1110
1211
1312
1413
1514
1615
1716
1817
1918
2019
2120
2221
2322
2423
2524
2625
2726
2827
2928
3029
3130
3231
3332
3433!!
3534""
3635##
3736$$
3837%%
3938&&
4039''
4140((
4241))
4342**
4443++
4544,,
4645--
4746..
4847//
494800
504911
515022
525133
535244
545355
555466
565577
575688
585799
5958::
6059;;
6160<<
6261==
6362>>
6463??
6564@@
6665AA
6766BB
6867CC
6968DD
7069EE
7170FF
7271GG
7372HH
7473II
7574JJ
7675KK
7776LL
7877MM
7978NN
8079OO
8180PP
8281QQ
8382RR
8483SS
8584TT
8685UU
8786VV
8887WW
8988XX
9089YY
9190ZZ
9291[[
9392\\
9493]]
9594^^
9695__
9796``
9897aa
9998bb
10099cc
101100dd
102101ee
103102ff
104103gg
105104hh
106105ii
107106jj
108107kk
109108ll
110109mm
111110nn
112111oo
113112pp
114113qq
115114rr
116115ss
117116tt
118117uu
119118vv
120119ww
121120xx
122121yy
123122zz
124123{{
125124||
126125}}
127126~~
128127
129128
130129
131130
132131ƒ
133132
134133
135134
136135
137136ˆ
138137
139138Š
140139
141140Œ
142141
143142Ž
144143
145144
146145
147146
148147
149148
150149
151150
152151
153152˜
154153
155154š
156155
157156œ
158157
159158ž
160159Ÿ
161160
162161¡¡
163162¢¢
164163££
165164¤¤
166165¥¥
167166¦¦
168167§§
169168¨¨
170169©©
171170ªª
172171««
173172¬¬
174173
175174®®
176175¯¯
177176°°
178177±±
179178²²
180179³³
181180´´
182181µµ
183182
184183··
185184¸¸
186185¹¹
187186ºº
188187»»
189188¼¼
190189½½
191190¾¾
192191¿¿
193192ÀÀ
194193ÁÁ
195194ÂÂ
196195ÃÃ
197196ÄÄ
198197ÅÅ
199198ÆÆ
200199ÇÇ
201200ÈÈ
202201ÉÉ
203202ÊÊ
204203ËË
205204ÌÌ
206205ÍÍ
207206ÎÎ
208207ÏÏ
209208ÐÐ
210209ÑÑ
211210ÒÒ
212211ÓÓ
213212ÔÔ
214213ÕÕ
215214ÖÖ
216215××
217216ØØ
218217ÙÙ
219218ÚÚ
220219ÛÛ
221220ÜÜ
222221ÝÝ
223222ÞÞ
224223ßß
225224àà
226225áá
227226ââ
228227ãã
229228ää
230229åå
231230ææ
232231çç
233232èè
234233éé
235234êê
236235ëë
237236ìì
238237íí
239238îî
240239ïï
241240ðð
242241ññ
243242òò
244243óó
245244ôô
246245õõ
247246öö
248247÷÷
249248øø
250249ùù
251250úú
252251ûû
253252üü
254253ýý
255254þþ
256255ÿÿ
257256Ā#VALUE!
258257ā#VALUE!
259258Ă#VALUE!
260259ă#VALUE!
261260Ą#VALUE!
262261ą#VALUE!
263262Ć#VALUE!
264263ć#VALUE!
265264Ĉ#VALUE!
266265ĉ#VALUE!
267266Ċ#VALUE!
268267ċ#VALUE!
269268Č#VALUE!
270269č#VALUE!
271270Ď#VALUE!
272271ď#VALUE!
273272Đ#VALUE!
274273đ#VALUE!
275274Ē#VALUE!
276275ē#VALUE!
277276Ĕ#VALUE!
278277ĕ#VALUE!
279278Ė#VALUE!
280279ė#VALUE!
281280Ę#VALUE!
282281ę#VALUE!
283282Ě#VALUE!
284283ě#VALUE!
285284Ĝ#VALUE!
286285ĝ#VALUE!
287286Ğ#VALUE!
288287ğ#VALUE!
289288Ġ#VALUE!
290289ġ#VALUE!
291290Ģ#VALUE!
292291ģ#VALUE!
293292Ĥ#VALUE!
294293ĥ#VALUE!
295294Ħ#VALUE!
296295ħ#VALUE!
297296Ĩ#VALUE!
298297ĩ#VALUE!
299298Ī#VALUE!
300299ī#VALUE!
Sheet2
Cell Formulas
RangeFormula
A2:A501A2=SEQUENCE(500)
B2:B501B2=UNICHAR(A2#)
C2:C501C2=CHAR(A2#)
Dynamic array formulas.
 
Upvote 0
Hi, UNICODE() and UNICHAR() deal with the UNICODE character set, CODE() and CHAR() deal with the ASCII character set.

An edited note, ASCII is a subset of the UNICODE set.
 
Upvote 0
Solution
Hi,
Is it fair to say that ASCII is a subset of Unicode and represents a limited range of characters primarily used in the English language. Whereas, Unicode is a more comprehensive encoding scheme that can represent characters from multiple languages and symbols.
 
Upvote 0
Hi, UNICODE() and UNICHAR() deal with the UNICODE character set, CODE() and CHAR() deal with the ASCII character set.

An edited note, ASCII is a subset of the UNICODE set.
If ASCII is the subset of UNICODE, I find that interesting UNICHAR(128-159) returned blanks, while CHAR(128-159) did not.
 
Upvote 0
The first 128 characters use the same encoding, the rest of the ASCII character set uses a different encoding. UNICODE is prevalent these days.
 
Upvote 0
The first 128 characters use the same encoding, the rest of the ASCII character set uses a different encoding. UNICODE is prevalent these days.
That makes sense for the difference. Would you go as far as saying that UNICODE() is always preferred over CODE()?
 
Upvote 0
I'd be lying if I said I always used it over CODE() after all CODE() does have 3 fewer letters 😜
 
Upvote 0
Fair point but we have intellisense drop down. Thanks for your time. :)
 
Upvote 0
CODE() has always worked for my purposes and I have never had to use UNICODE(), but I am almost always working with the first 128 values.
 
Upvote 0

Forum statistics

Threads
1,216,022
Messages
6,128,326
Members
449,441
Latest member
khankins

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top