-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathindex.html
executable file
·422 lines (325 loc) · 21.4 KB
/
index.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Unicode code converter</title>
<meta name="description" content="Helps you convert between Unicode character numbers, characters, UTF-8 and UTF-16 code units in hex, percent escapes,and Numeric Character References (hex and decimal)." />
<link rel="stylesheet" href="../shared/style/docs.css" />
<link rel="stylesheet" href="localstyle.css" />
<script src="../shared/code/boilerplate.js"></script>
<script src="conversionfunctions.js">//</script>
<script src="example.js">//</script>
<script src="entities.js">//</script>
<style>
.options { font-size: 80%; }
td { vertical-align: middle; }
body.app #sitelinks { margin-bottom: 0; }
#example p { margin-right:7.5%; font-size:90%; }
textarea { padding: 0 5px; }
#versionInfo a { font-weight: bold; }
.subhead { color: brown; margin-left: .75em; }
.copy { margin: 0 10px; padding: 0 .5em; font-size: .85em; background-color: darkgray; color: white; border: 0; }
.copy:hover { color: brown; }
.convert { margin: 0 10px; }
</style>
<!--
Copyright (C) 2007 Richard Ishida [email protected]
This program is free software; you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version as long as you point to
http://rishida.net/ in your code.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details. http://www.gnu.org/licenses/gpl.html
-->
</head>
<body class="app">
<header>
<div id="header-boilerplate"></div>
<script>document.getElementById('header-boilerplate').innerHTML = bp_appHeader('../shared/images/world.gif','Unicode code converter','v10');</script>
</header>
<section>
<!--p style="font-size: 120%; float:left;">This is version 9beta. Please <a style="font-weight:bold;" href="https://github.com/r12a/app-conversion/issues">raise any issues here</a>.</p-->
<details>
<summary style="margin-right: 5%; margin-top: 1em;" dir="rtl" onclick="escapedInput.value=window.example_test;">Show instructions</summary>
<p style="clear: both;">Type or paste text in the green box and click on the <code>Convert</code> button above it. Alternative representations will appear in all the other boxes. You can also do the same in any grey box, if you want to target only certain types of escaped text. You can then cut & paste the results into your document. <img src="selectall.png" alt="Select" /> selects all the text in a box (useful for deleting), and <img src="copy.png" alt="Copy"/> copies the text to the clipboard, if your browser supports that. See the <a href="help">help page</a> for other options.</p>
<p><b class="leadin">Worked example.</b> The text in the field with a green background currently contains a variety of escapes. Normally you would simply click on the <code>Convert</code> button just above the field to show the various escape formats below. Note, however, that this (unusually convoluted) text represents two characters using just a code point number – therefore, for this particular example, you should select <code>Treat bare numbers as Hex code points</code> (or decimal) to convert those numbers as well as the other escapes. You should also ensure that the checkbox next to <code>Convert \n etc</code> is selected, in order to convert the <code>\n</code> and <code>\t</code> escapes.</p>
<p>After selecting those options, click on the <code>Convert</code> button.</p>
<p>You will then see the conversion results in the grey boxes. You can use checkboxes alongside many boxes to tweak the results. For more information on each of the grey boxes, see the <a href="help">help page</a>.</p>
</details>
</section>
<table id="converter" style="clear: both;">
<tr>
<td colspan="2">
<button value="Convert"
onclick="displayResults(convertAllEscapes(escapedInput.value, document.getElementById('numbers').value), escapedInput.id);
return false;" style="font-size:140%;" >Convert</button>
<button class="copy" onclick="
escapedInput.value = '';
codePoints.value = '';
decCodePoints.value = '';
UTF8.value = '';
UTF16.value = '';
zeroX.value = '';
hexNCRs.value = '';
decNCRs.value = '';
Unicode.value = '';
pEsc.value = '';
rust.value = '';
jEsc.value = '';
perl.value = '';
chars.value = '';
CSS.value = '';
XML.value = '';
escapedInput.focus(); return false;" >Clear</button>
<span class="options">
<label>Treat bare numbers as
<select id="numbers" style="border: 0; color: brown; font-size: 90%;">
<option value="none">Just numbers</option>
<option value="hex">Hex code points</option>
<option value="dec">Dec code points</option>
<option value="utf8">UTF-8 units</option>
<option value="utf16">UTF-16 units</option>
</select>
</label>
<label>Convert \n etc<input type="checkbox" id="singleletterescapes" checked /></label>
</span>
<button id="extract" onClick="escapedInput.value = extractEscapes(document.getElementById('escapedInput').value)">Extract</button>
<a href="help#use" target="_blank"><img src="images/help.png" alt="help"/></a><br/>
<textarea id="escapedInput" name="escapedInput" rows="3" cols="5" style="background-color: #DFD; color:#333; height:7em;" placeholder="Add characters here, then press Convert."></textarea></td>
</tr>
<tr>
<td colspan="2" style="padding-top: 20px;"><!-- *********** CHARACTERS *********** -->
<span class="subhead">Characters</span>
<button class="copy" onclick="chars.focus(); chars.select(); document.execCommand('copy'); return false;" >Copy</button>
<!--button
onclick="if (chars.value== '') { alert('No characters in the text area.'); } else { var list = window.open('/rishida/tools/analysestring?list='+encodeURIComponent(chars.value)+'&smallgraphics=on&compact=on&noblock=on&nounicode=on&nonotes=on', 'list'); list.focus(); }
return false;" >View names</button-->
<!--button
onclick="var list = window.open( '/rishida/uniview/?codepoints='+convertChar2CP( chars.value ) );
return false;" >View in UniView</button-->
<button
onclick="var list = window.open( '/uniview/?charlist='+encodeURIComponent(chars.value ));
return false;" >View in UniView</button>
<button class="convert"
onclick="displayResults( chars.value, chars.id ); return false;" >Convert</button>
<a href="help#characters" target="_blank"><img src="images/help.png" alt="help"/></a>
<br/>
<textarea id="chars" name="chars" rows="2" cols="5"></textarea></td>
</tr>
<tr>
<td colspan="2"><!-- *********** HTML/XML *********** -->
<span class="subhead">HTML/XML</span>
<button class="copy" onclick="XML.focus(); XML.select(); document.execCommand('copy'); return false;" >Copy</button>
<span class="options" id="xmlOptions">
<label>Escape invisible characters<input class="check" type="checkbox" id="xmlinvisibles" data-fn="convertinvisibles" checked="checked" onclick="XML.value = convertCharStr2XML(convertXML2Char(XML.value), getParameters(parentNode.parentNode));" /></label>
<label>Convert bidi controls to HTML markup<input type="checkbox" id="xmlbidimarkup" data-fn="bidimarkup" onclick="XML.value = convertCharStr2XML(convertXML2Char(XML.value), getParameters(parentNode.parentNode));"/></label>
</span>
<button class="convert"
onclick="displayResults( convertXML2Char(XML.value), XML.id ); return false;" >Convert</button>
<a href="help#html" target="_blank"><img src="images/help.png" alt="help"/></a><br/>
<textarea id="XML" name="XML" rows="2" cols="5"></textarea>
</td>
</tr>
<tr>
<td><!-- *********** HEX NCRS *********** -->
<span class="subhead">Hex NCRs</span>
<button class="copy" onclick="hexNCRs.focus(); hexNCRs.select(); document.execCommand('copy'); return false;" >Copy</button>
<span class="options" id="hexNCROptions"><label>Show ascii<input class="check" type="checkbox" id="hexncrascii" checked="checked" data-fn="ascii"
onclick="hexNCRs.value = convertCharStr2SelectiveCPs(convertHexNCR2Char(hexNCRs.value), getParameters(parentNode), true, '&#x', ';', 'hex');" /></label></span>
<button class="convert"
onclick="displayResults( convertHexNCR2Char(hexNCRs.value), hexNCRs.id ); return false;" >Convert</button>
<a href="help#hexNCRs" target="_blank"><img src="images/help.png" alt="help"/></a><br/>
<textarea id="hexNCRs" name="hexNCRs" rows="3" cols="5"></textarea></td>
<td><!-- *********** DEC NCRS *********** -->
<span class="subhead">Decimal NCRs</span>
<button class="copy" onclick="decNCRs.focus();decNCRs.select(); document.execCommand('copy'); return false;" >Copy</button>
<span class="options" id="decNCROptions"><label>Show ascii<input type="checkbox" id="decncrascii" checked="checked" data-fn="ascii"
onclick="decNCRs.value = convertCharStr2SelectiveCPs(convertDecNCR2Char(decNCRs.value), getParameters(parentNode), true, '&#', ';', 'dec');" /></label>
</span>
<button class="convert"
onclick="displayResults( convertDecNCR2Char(decNCRs.value), decNCRs.id ); return false;" >Convert</button>
<a href="help#decNCRs" target="_blank"><img src="images/help.png" alt="help"/></a><br/>
<textarea id="decNCRs" name="decNCRs" rows="3" cols="5"></textarea></td>
</tr>
<tr>
<td><!-- *********** JAVASCRIPT ESCAPES *********** -->
<span class="subhead">JS/Java/C</span>
<button class="copy" onclick="jEsc.focus();jEsc.select(); document.execCommand('copy'); return false;" >Copy</button>
<span class="options" id="jEscOptions">
<label>ES6<input class="check" type="checkbox" checked data-fn="es6styleSC" id="es6styleSC" onclick="document.getElementById('cstyleSC').checked =false; jEsc.value = convertCharStr2jEsc(convertjEsc2Char(jEsc.value, true), getParameters(parentNode));"/></label>
<label>C-style<input class="check" type="checkbox" data-fn="cstyleSC" id="cstyleSC" onclick="document.getElementById('es6styleSC').checked =false; jEsc.value = convertCharStr2jEsc(convertjEsc2Char(jEsc.value, true), getParameters(parentNode));" /></label>
<label>\n etc<input class="check" type="checkbox" data-fn="noCR" id="noCR" onclick="jEsc.value = convertCharStr2jEsc(convertjEsc2Char(jEsc.value, true), getParameters(parentNode));"/></label>
</span>
<!--button value="Switch"
onclick="jEsc.value = convert2C( jEsc.value );
return false;" >C-style Supp. Chars.</button-->
<button class="convert"
onclick="displayResults(convertjEsc2Char(jEsc.value, true), jEsc.id); return false;" >Convert</button>
<a href="help#javascript" target="_blank"><img src="images/help.png" alt="help"/></a><br/>
<textarea id="jEsc" name="jEsc" rows="3" cols="5"></textarea></td>
<td><!-- *********** RUST ESCAPES *********** -->
<span class="subhead">Rust/Ruby</span>
<button class="copy" onclick="rust.focus();rust.select(); document.execCommand('copy'); return false;" >Copy</button>
<span class="options" id="rustOptions">
<label>\n etc<input class="check" type="checkbox" data-fn="noCR" id="noRustCR" onclick="rust.value = convertCharStr2Rust(convertRust2Char(rust.value, true), getParameters(parentNode));"/></label>
</span>
<button class="convert"
onclick="displayResults(convertRust2Char(rust.value), rust.id); return false;" >Convert</button>
<a href="help#rust" target="_blank"><img src="images/help.png" alt="help"/></a><br/>
<textarea id="rust" name="rust" rows="3" cols="5"></textarea></td>
</tr>
<tr>
<td><!-- *********** CSS ESCAPES *********** -->
<span class="subhead">CSS</span>
<button class="copy" onclick="CSS.focus(); CSS.select(); document.execCommand('copy'); return false;" >Copy</button>
<button class="convert"
onclick="displayResults(convertCSS2Char(CSS.value, true), CSS.id); return false;" >Convert</button>
<a href="help#css" target="_blank"><img src="images/help.png" alt="help"/></a><br/>
<textarea id="CSS" name="CSS" rows="3" cols="5"></textarea></td>
<td><!-- *********** \X NOTATION *********** -->
<span class="subhead">Perl/UTR#18</span>
<button class="copy" onclick="perl.focus(); perl.select(); document.execCommand('copy'); return false;" >Copy</button>
<span class="options" id="perlOptions">
<label>\n etc<input class="check" type="checkbox" data-fn="noCR" id="noperlCR" onclick="perl.value = convertCharStr2Perl(convertPerl2Char(perl.value, true), getParameters(parentNode));"/></label>
</span>
<button class="convert"
onclick="displayResults(convertPerl2Char(perl.value), perl.id); return false;" >Convert</button>
<a href="help#perl" target="_blank"><img src="images/help.png" alt="help"/></a><br/>
<textarea id="perl" name="perl" rows="3" cols="5"></textarea></td>
</tr>
<tr>
<td colspan="2"><!-- *********** % ESCAPES *********** -->
<span class="subhead">Percent encoding for URIs</span>
<button class="copy" onclick="pEsc.focus(); pEsc.select(); document.execCommand('copy'); return false;" >Copy</button>
<button class="convert"
onclick="displayResults( convertpEnc2Char(pEsc.value), pEsc.id ); return false;" >Convert</button>
<a href="help#percentEncoding" target="_blank"><img src="images/help.png" alt="help"/></a><br/>
<textarea id="pEsc" name="pEsc" rows="2" cols="5"></textarea></td>
</tr>
<tr>
<td><!-- *********** U+ *********** -->
<span class="subhead">U+hex</span>
<button class="copy" onclick="Unicode.focus(); Unicode.select(); document.execCommand('copy'); return false;" >Copy</button>
<span class="options"><label>Show ascii<input class="check" type="checkbox" id="unicodeascii" checked="checked"
onclick="preserve = 'none';
if (this.checked) { preserve = 'ascii'; }
Unicode.value = convertCharStr2CP(convertUnicode2Char(Unicode.value), preserve, true, 'unicode');"/></label>
</span>
<button onClick="Unicode.value=Unicode.value.replace(/([a-fA-F0-9])U\+/g,'$1 U+')">Separate</button>
<button class="convert"
onclick="displayResults( convertUnicode2Char(Unicode.value), Unicode.id ); return false;" >Convert</button>
<a href="help#UHex" target="_blank"><img src="images/help.png" alt="help"/></a><br/>
<textarea id="Unicode" name="Unicode" rows="3" cols="5"></textarea></td>
<td><!-- *********** 0x... *********** -->
<span class="subhead">0x...</span>
<button class="copy" onclick="zeroX.focus(); zeroX.select(); document.execCommand('copy'); return false;" >Copy</button>
<span class="options"><label>Show ascii<input class="check" type="checkbox" id="zeroXascii" checked="checked"
onclick="preserve = 'none';
if (this.checked) { preserve = 'ascii'; }
zeroX.value = convertCharStr2CP(convert0x2Char(zeroX.value), preserve, true, 'zerox');" /></label>
</span>
<button onClick="zeroX.value=zeroX.value.replace(/([a-fA-F0-9])0x/g,'$1 0x')">Separate</button>
<button class="convert"
onclick="displayResults( convert0x2Char(zeroX.value), zeroX.id ); return false;" >Convert</button>
<a href="help#ZeroX" target="_blank"><img src="images/help.png" alt="help"/></a><br/>
<textarea id="zeroX" name="zeroX" rows="3" cols="5"></textarea></td>
</tr>
<tr>
<td><!-- *********** UTF-8 *********** -->
<span class="subhead">UTF-8 code units</span>
<button class="copy" onclick="UTF8.focus(); UTF8.select(); document.execCommand('copy'); return false;" >Copy</button>
<button class="convert"
onclick="displayResults(convertUTF82Char(UTF8.value), UTF8.id); return false;" >Convert</button>
<a href="help#utf8" target="_blank"><img src="images/help.png" alt="help"/></a><br/>
<textarea id="UTF8" name="UTF8" rows="3" cols="5"></textarea></td>
<td><!-- *********** UTF-16 *********** -->
<span class="subhead">UTF-16 code units</span>
<button class="copy" onclick="UTF16.focus(); UTF16.select(); document.execCommand('copy'); return false;" >Copy</button>
<button class="convert"
onclick="displayResults(convertUTF162Char(UTF16.value), UTF16.id); return false;" >Convert</button>
<a href="help#utf16" target="_blank"><img src="images/help.png" alt="help"/></a> <br/>
<textarea id="UTF16" name="UTF16" rows="3" cols="5"></textarea></td>
</tr>
<tr>
<td><!-- *********** CODE POINTS *********** -->
<span class="subhead">Hex/UTF-32</span>
<button class="copy" onclick="codePoints.focus(); codePoints.select(); document.execCommand('copy'); return false;" >Copy</button>
<span class="options" id="hexCPOptions">
<label>Keep ascii
<input class="check" type="checkbox" id="hexcpascii" /></label>
<label>Pad <select id="hexcppad" onclick="
if (document.getElementById('hexcpascii').checked) {
codePoints.value = convertCharStr2CP(convertNumbers2Char(codePoints.value, 'hex'), 'ascii', document.getElementById('hexcppad').value, 'hex', document.getElementById('hexcpascii').checked) }
else { codePoints.value = convertCharStr2CP(convertSpaceSeparatedNumbers2Char(codePoints.value, 'hex'), 'none', document.getElementById('hexcppad').value, 'hex', document.getElementById('hexcpascii').checked)}
;" style="border: 0; color: brown; font-size: 90%;">
<!--option value="0">0</option-->
<option value="2">2</option>
<option value="4" selected>4</option>
<option value="8">8</option>
</select></label>
</span>
<button class="convert"
onclick="if (document.getElementById('hexcpascii').checked) {
displayResults( convertNumbers2Char(codePoints.value, 'hex'), codePoints.id ); }
else { displayResults( convertSpaceSeparatedNumbers2Char(codePoints.value, 'hex'), codePoints.id )}
return false;" >Convert</button>
<a href="help#hexCP" target="_blank"><img src="images/help.png" alt="help"/></a><br/>
<textarea id="codePoints" name="codePoints" rows="3" cols="5"></textarea></td>
<td><!-- *********** DEC CODE POINTS *********** -->
<span class="subhead">Decimal</span>
<button class="copy" onclick="decCodePoints.focus(); decCodePoints.select(); document.execCommand('copy'); return false;" >Copy</button>
<span class="options">
<label>Keep ascii
<input class="check" type="checkbox" id="deccpascii" /></label>
</span>
<button class="convert"
onclick="if (document.getElementById('deccpascii').checked) {
displayResults( convertNumbers2Char(decCodePoints.value, 'dec'), decCodePoints.id ); }
else { displayResults( convertSpaceSeparatedNumbers2Char(decCodePoints.value, 'dec'), decCodePoints.id ) }
return false;" >Convert</button>
<a href="help#decCP" target="_blank"><img src="images/help.png" alt="help"/></a><br/>
<textarea id="decCodePoints" name="decCodePoints" rows="3" cols="5"></textarea></td>
</tr>
</table>
<p><a href="help#versionInfo">Summary of changes in this version</a>.</p>
<div class="smallprint"><span id="version">
See <a href="https://github.com/r12a/app-conversion/commits/gh-pages">recent changes</a>.
Make a <a href="https://github.com/r12a/app-conversion/issues/new">comment</a>.
Licence <a rel="license" href="http://creativecommons.org/licenses/by/4.0/">CC-By</a> © <a href="mailto:[email protected]">r12a</a>
</span>
</div>
<script>
var escapedInput = document.getElementById('escapedInput');
var codePoints = document.getElementById('codePoints');
var decCodePoints = document.getElementById('decCodePoints');
var UTF8 = document.getElementById('UTF8');
var UTF16 = document.getElementById('UTF16');
var zeroX = document.getElementById('zeroX');
var hexNCRs = document.getElementById('hexNCRs');
var decNCRs = document.getElementById('decNCRs');
var Unicode = document.getElementById('Unicode');
var pEsc = document.getElementById('pEsc');
var rust = document.getElementById('rust');
var perl = document.getElementById('perl');
var jEsc = document.getElementById('jEsc');
var chars = document.getElementById('chars');
var CSS = document.getElementById('CSS');
var XML = document.getElementById('XML');
// check for parameters and take appropriate action
parameters = location.search.split('&')
parameters[0] = parameters[0].substring(1)
for (var p=0;p<parameters.length;p++) {
pairs = parameters[p].split('=')
if (pairs[0] == 'q' && pairs[1]) {
escapedInput.value = convertpEnc2Char(pairs[1])
displayResults(convertAllEscapes(escapedInput.value, "none"), escapedInput.id)
}
}
</script>
</body>
</html>