-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
454 lines (399 loc) · 14.7 KB
/
index.html
File metadata and controls
454 lines (399 loc) · 14.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>The Unicode Text Debugger @ unicode.run</title>
<!-- https://rsms.me/inter/ -->
<link rel="preconnect" href="https://rsms.me/">
<link rel="stylesheet" href="https://rsms.me/inter/inter.css">
<style>
:root {
font-family: Inter, sans-serif;
font-feature-settings: 'calt' 0, 'tnum' 1, 'zero' 1, 'ss02' 1;
}
@supports (font-variation-settings: normal) {
:root { font-family: InterVariable, sans-serif; }
}
body { font-family: inherit !important; } /* override bootstrap reset -->
</style>
<link rel="stylesheet" href="lib/bootstrap.min.css"></link>
<script src="lib/string-split-grapheme-clusters.js"></script>
<script src="lib/bootstrap.bundle.min.js"></script>
<script src="lib/unicodeCharacterDatabase.json"></script>
<script type="module" src="index.mjs"></script>
<style>
/* We don't care about Boostrap's breakpoints.
Just set a maximum width and fill the viewport
at smaller sizes. */
.container {
max-width: 1320px;
}
body
{
font-size: 14px;
}
.unicode-content
{
}
.unicode-content.codepoint-space span
{
display: inline-block;
border: 1px dotted white;
border-radius: .1em;
line-height: 100%;
}
.unicode-content.codepoint-abbreviation span
{
display: inline-block;
border-radius: .2em;
padding: 2px;
line-height: 100%;
font-weight: bold;
font-family: sans-serif;
font-size: 70%;
}
#header
{
padding: 1rem 0;
background-color: inherit;
}
h1
{
font-size: 2rem;
}
#text-length
{
margin: 1rem 0;
}
#text-length > div
{
display: inline-block;
vertical-align: top;
cursor: default;
margin-right: 1.25em;
}
#text-length > div > span
{
}
#text-length > div > span:first-child
{
font-size: 110%;
font-weight: bold;
margin-right: .15em;
}
#select-escape-code-format
{
position: absolute; /* so that when it's exapnded it doesn't shift other content down */
margin: -.25em;
padding: .25em;
min-width: 75%;
}
#select-escape-code-format a, #select-input-format a {
cursor: pointer;
margin: .25em;
text-decoration: underline;
}
#select-escape-code-format a {
display: none;
}
#select-escape-code-format a[active], #select-input-format a[active] {
display: inline-block;
font-weight: bold;
}
#select-escape-code-format:hover a, #select-escape-code-format.expanded a {
display: inline-block;
}
a#select-escape-code-format-expander {
display: inline-block;
text-decoration: none;
}
#select-escape-code-format:hover #select-escape-code-format-expander {
display: none;
}
#bidi-renderings
{
margin-top: 1em;
}
#bidi-renderings th, #bidi-renderings td
{
min-width: 10vw;
text-align: center;
}
#bidi-renderings td
{
font-size: 1.5rem;
}
div.cluster-container
{
display: inline-block;
}
div.cluster-container.complex
{
margin: 1em 1em 1em -.25em; /* left negative margin shouldn't be more than half of the .container padding so that the border doesn't go outside of the viewport */
padding: 1em;
border: 1px solid black;
}
.cluster_display
{
font-size: 275%;
text-align: center;
}
.card.codepoint
{
display: inline-block;
vertical-align: top;
width: 12em;
margin: 0 2em 2em 0;
min-height: 13em;
cursor: pointer;
}
.card.codepoint .codepoint_display
{
cursor: text;
font-size: 275%;
text-align: center;
white-space: pre; /* prevents space characters from collapsing to no size */
}
.codepoint_normalization .card.codepoint
{
font-size: 80%;
}
.card.codepoint .codepoint_hex
{
cursor: text;
font-size: 1.1rem;
font-weight: 300;
margin-bottom: .75em;
text-align: center;
}
.codepoint_name
{
margin-bottom: .5em;
}
.codepoint_attributes
{
font-size: .9rem;
}
.codepoint_category
{
margin-right: 1em;
border: 1px solid grey;
padding: 1px;
}
.escapecode
{
display: none;
}
#examples, #about
{
font-size: 16px;
}
#examples div
{
margin: .5em .5em .5em -.5em;
padding: .5em;
cursor: pointer;
}
#examples div span:first-child
{
font-size: 150%;
font-weight: bold;
margin: .5em;
}
/* Color Schemes */
/* unfortunatly I couldn't come up with a nice looking
default light color scheme, so dark for everyone
@media (prefers-color-scheme: dark) { */
body
{
background-color: #274154;
color: #EEE;
}
a, a:focus, a:visited
{
color: #EEE;
}
a[active]
{
color: yellow;
}
#select-escape-code-format
{
}
#select-escape-code-format:hover, #select-escape-code-format.expanded {
background-color: black;
}
#select-escape-code-format a
{
color: white;
}
#text-length > div > span:first-child
{
color: white;
}
.cluster-container.complex
{
border-color: #273344;
background-color: #2A4759;
}
.card.codepoint
{
background-color: #273344;
color: white;
}
.card.codepoint:hover
{
background-color: #112244;
}
.card.codepoint.selected
{
background-color: #278854; /* after hover */
}
.unicode-content.codepoint-space span
{
color: yellow;
border-color: yellow;
}
.unicode-content.codepoint-abbreviation span
{
background: #DDDD55;
color: black;
}
.unicode-content.codepoint-illegal
{
color: red;
}
#examples div:hover
{
background-color: #273344;
}
/* } // media */
</style>
</head>
<body>
<div id="header" class="fixed-top">
<div class="container">
<table style="width: 100%;">
<tr valign="top">
<td style="width: 0;">
<img id="logo" src="logo.png" style="width: 5rem; height: 5rem; margin-right: 1rem;">
</td>
<td>
<div id="select-input-format" style="line-height: 135%; margin-top: .75rem; margin-bottom: .5rem;">
Paste
<a data-key="text" active="" href="#" onclick="return false;">Text</a>
or
<a data-key="utf32" href="#" onclick="return false;">UTF-32</a> /
<a data-key="utf16" href="#" onclick="return false;">UTF-16BE</a>
in hex to run the Unicode text debugger.
</div>
<!-- the textarea has dir="auto" to work best for bidirectional text, and then I've added text-align: left to the CSS so that RTL text doesn't appear like it's missing all the way at the other end of the box -->
<textarea id="input" style="width: 100%; height: 2.5rem; margin: 0; padding: .25rem; line-height: 110%; font-size: 1.5rem; text-align: left;" class="unicode-content"
placeholder="Paste some text here." dir="auto"></textarea>
<div id="select-escape-code-format" style="margin-top: .25em">
Show Below:
<span>
</span>
<a id="select-escape-code-format-expander" href="#" onclick="document.getElementById('select-escape-code-format').classList.toggle('expanded'); return false;">⋯</a>
</div>
<div style="height: 2em;"> </div> <!-- since select-escape-code-format is absolutely positioned, make something of about the same height in its collapsed state -->
</td>
</tr>
</table>
</div>
</div>
<hr>
<div id="content-area" class="container">
<div id="text-length">
<div data-bs-toggle="popover"
data-bs-content="Technically called “extended grapheme clusters”. Apparently Swift and Elixir report lengths this way, but they may implement different EGC rules than on this page.">
<span id="text-length-egcs"></span>
<span>Character<span>s</span></span>
</div>
<div data-bs-toggle="popover"
data-bs-content="Languages including Python, whose internal representation of text is UTF-32, will give this length.">
<span id="text-length-codepoints"></span>
<span>Code Point<span>s</span></span>
</div>
<div data-bs-toggle="popover"
data-bs-content="Languages including JavaScript, C#, Java, and C, whose internal representation of text is UTF-16, will give this length.">
<span id="text-length-utf16"></span>
<span>UTF-16 Unit<span>s</span></span>
</div>
<div data-bs-toggle="popover"
data-bs-content="Most files are saved in UTF-8 encoding.">
<span id="text-length-utf8"></span>
<span>UTF-8 Byte<span>s</span></span>
</div>
</div>
<div id="warnings" style="margin: 2em 0">
</div>
<div id="codepoints">
</div>
<div id="examples">
<hr style="margin: 2rem 0 3em 0;">
<h2>Try an example!</h2>
<div>
<span>🧑🏾❤️💋🧑🏻</span>
<span>The most complex emoji in the current Unicode standard is composd of 10 code points including skin color modifiers, zero-width joiners, and a variation selector.</span>
</div>
<div>
<span>S̶t̶r̶i̶k̶e̶о𝘂𝘁</span>
<span>See how combining characters and misusing unusual characters can be used to create interesting text effects and homographs.</span>
</div>
<div>
<span>Å != Å</span>
<span>Learn about composing characters and normalized forms.</span>
</div>
<div>
<span>12345</span>
<span>This text renders backwards from the order of its characters using BIDI control code points. Inspired by <a href="https://trojansource.codes/">https://trojansource.codes/</a>.</span>
</div>
<div>
<span>Hi! ‏(שלום!)‏</span>
<span>This example contains bidirectional text with BIDI glyph mirroring and right-to-left markers. Inspired by <a href="https://blog.georeactor.com/osm-1">https://blog.georeactor.com/osm-1</a>.</span>
</div>
<div>
<span>(שלום!)</span>
<span>This bidirectional text displays differently depending on context. Inspired by <a href="https://blog.georeactor.com/osm-1">https://blog.georeactor.com/osm-1</a>.</span>
</div>
<div>
<span>↙ ~ ↙️ and 你好! ~ 你好!︁</span>
<span>Examples of an emoji variation sequence and an East Asian punctuation positional variant using variation selectors.</span>
</div>
<p>Send me other interesting Unicode examples at <a href="https://mastodon.joshdata.me/@josh">@josh@joshdata.me on Mastodon</a>.</p>
</div>
<div id="about">
<hr style="margin: 2rem 0 3em 0;">
<h2>About Unicode.run</h2>
<p>Text is <i>unexpectedly</i> complicated. Use Unicode.run to debug text.</p>
<p>Here are some things you can do here:</p>
<ul>
<li>See each code point’s escape code in a variety of programming languages.</li>
<li>See the “length” of the text as it would be reported in different programming languages.</li>
<li>See when characters (technically “extended grapheme clusters”) are composed of multiple code points.</li>
<li>Click code points in the debugger output to highlight them in the text. (In Firefox you can also select text to highlight the code points in the debugger output.)</li>
<li>Switch between the text and its UTF-32 or UTF-16BE hex encodings at the top of the page.</li>
<li>See where text changes direction in bidirectional text, and get warnings when text direction depends on where it is used. Mirrored glyphs in bidirectional text are also noted.</li>
<li>Get warnings about hidden code points that can alter the display of the text (see <a href="https://trojansource.codes/">https://trojansource.codes/</a>), invalidly placed combining code points, invalid code points, and characters that are not in normalized form.</li>
</ul>
<p></p>
<p>This is a project by <a href="https://joshdata.me/">JoshData</a>.</p>
<p>Source code is at <a href="https://github.com/JoshData/unicode.run">https://github.com/JoshData/unicode.run</a>.</p>
<p>Thanks to
<a href="https://www.npmjs.com/package/ucd-full">ucd-full</a> (based on Unicode 15.1),
<a href="https://github.com/stdlib-js/string-split-grapheme-clusters">stdlib-js/string-split-grapheme-clusters</a> (based on Unicode 13),
<a href="https://www.npmjs.com/package/bidi-js">bidi-js</a> (based on Unicode 13),
<a href="https://www.npmjs.com/package/html-entities">html-entities</a>,
and the <a href="https://rsms.me/inter/">Inter Typeface</a>.</p>
<p>Nikita Prokopov’s <a href="https://tonsky.me/blog/unicode/">The Absolute Minimum Every Software Developer Must Know About Unicode in 2023 (Still No Excuses!)</a> was inspiration for this project.</p>
</div>
</div> <!-- /container -->
</body>
<script>
const popoverTriggerList = document.querySelectorAll('[data-bs-toggle="popover"]')
const popoverList = [...popoverTriggerList].map(popoverTriggerEl => new bootstrap.Popover(popoverTriggerEl,
{ trigger: 'hover focus' }))
</script>
</html>