]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/compat.py
New upstream version 2020.07.28
[youtubedl] / youtube_dl / compat.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3
4 import base64
5 import binascii
6 import collections
7 import ctypes
8 import email
9 import getpass
10 import io
11 import itertools
12 import optparse
13 import os
14 import platform
15 import re
16 import shlex
17 import shutil
18 import socket
19 import struct
20 import subprocess
21 import sys
22 import xml.etree.ElementTree
23
24
25 try:
26 import urllib.request as compat_urllib_request
27 except ImportError: # Python 2
28 import urllib2 as compat_urllib_request
29
30 try:
31 import urllib.error as compat_urllib_error
32 except ImportError: # Python 2
33 import urllib2 as compat_urllib_error
34
35 try:
36 import urllib.parse as compat_urllib_parse
37 except ImportError: # Python 2
38 import urllib as compat_urllib_parse
39
40 try:
41 from urllib.parse import urlparse as compat_urllib_parse_urlparse
42 except ImportError: # Python 2
43 from urlparse import urlparse as compat_urllib_parse_urlparse
44
45 try:
46 import urllib.parse as compat_urlparse
47 except ImportError: # Python 2
48 import urlparse as compat_urlparse
49
50 try:
51 import urllib.response as compat_urllib_response
52 except ImportError: # Python 2
53 import urllib as compat_urllib_response
54
55 try:
56 import http.cookiejar as compat_cookiejar
57 except ImportError: # Python 2
58 import cookielib as compat_cookiejar
59
60 if sys.version_info[0] == 2:
61 class compat_cookiejar_Cookie(compat_cookiejar.Cookie):
62 def __init__(self, version, name, value, *args, **kwargs):
63 if isinstance(name, compat_str):
64 name = name.encode()
65 if isinstance(value, compat_str):
66 value = value.encode()
67 compat_cookiejar.Cookie.__init__(self, version, name, value, *args, **kwargs)
68 else:
69 compat_cookiejar_Cookie = compat_cookiejar.Cookie
70
71 try:
72 import http.cookies as compat_cookies
73 except ImportError: # Python 2
74 import Cookie as compat_cookies
75
76 try:
77 import html.entities as compat_html_entities
78 except ImportError: # Python 2
79 import htmlentitydefs as compat_html_entities
80
81 try: # Python >= 3.3
82 compat_html_entities_html5 = compat_html_entities.html5
83 except AttributeError:
84 # Copied from CPython 3.5.1 html/entities.py
85 compat_html_entities_html5 = {
86 'Aacute': '\xc1',
87 'aacute': '\xe1',
88 'Aacute;': '\xc1',
89 'aacute;': '\xe1',
90 'Abreve;': '\u0102',
91 'abreve;': '\u0103',
92 'ac;': '\u223e',
93 'acd;': '\u223f',
94 'acE;': '\u223e\u0333',
95 'Acirc': '\xc2',
96 'acirc': '\xe2',
97 'Acirc;': '\xc2',
98 'acirc;': '\xe2',
99 'acute': '\xb4',
100 'acute;': '\xb4',
101 'Acy;': '\u0410',
102 'acy;': '\u0430',
103 'AElig': '\xc6',
104 'aelig': '\xe6',
105 'AElig;': '\xc6',
106 'aelig;': '\xe6',
107 'af;': '\u2061',
108 'Afr;': '\U0001d504',
109 'afr;': '\U0001d51e',
110 'Agrave': '\xc0',
111 'agrave': '\xe0',
112 'Agrave;': '\xc0',
113 'agrave;': '\xe0',
114 'alefsym;': '\u2135',
115 'aleph;': '\u2135',
116 'Alpha;': '\u0391',
117 'alpha;': '\u03b1',
118 'Amacr;': '\u0100',
119 'amacr;': '\u0101',
120 'amalg;': '\u2a3f',
121 'AMP': '&',
122 'amp': '&',
123 'AMP;': '&',
124 'amp;': '&',
125 'And;': '\u2a53',
126 'and;': '\u2227',
127 'andand;': '\u2a55',
128 'andd;': '\u2a5c',
129 'andslope;': '\u2a58',
130 'andv;': '\u2a5a',
131 'ang;': '\u2220',
132 'ange;': '\u29a4',
133 'angle;': '\u2220',
134 'angmsd;': '\u2221',
135 'angmsdaa;': '\u29a8',
136 'angmsdab;': '\u29a9',
137 'angmsdac;': '\u29aa',
138 'angmsdad;': '\u29ab',
139 'angmsdae;': '\u29ac',
140 'angmsdaf;': '\u29ad',
141 'angmsdag;': '\u29ae',
142 'angmsdah;': '\u29af',
143 'angrt;': '\u221f',
144 'angrtvb;': '\u22be',
145 'angrtvbd;': '\u299d',
146 'angsph;': '\u2222',
147 'angst;': '\xc5',
148 'angzarr;': '\u237c',
149 'Aogon;': '\u0104',
150 'aogon;': '\u0105',
151 'Aopf;': '\U0001d538',
152 'aopf;': '\U0001d552',
153 'ap;': '\u2248',
154 'apacir;': '\u2a6f',
155 'apE;': '\u2a70',
156 'ape;': '\u224a',
157 'apid;': '\u224b',
158 'apos;': "'",
159 'ApplyFunction;': '\u2061',
160 'approx;': '\u2248',
161 'approxeq;': '\u224a',
162 'Aring': '\xc5',
163 'aring': '\xe5',
164 'Aring;': '\xc5',
165 'aring;': '\xe5',
166 'Ascr;': '\U0001d49c',
167 'ascr;': '\U0001d4b6',
168 'Assign;': '\u2254',
169 'ast;': '*',
170 'asymp;': '\u2248',
171 'asympeq;': '\u224d',
172 'Atilde': '\xc3',
173 'atilde': '\xe3',
174 'Atilde;': '\xc3',
175 'atilde;': '\xe3',
176 'Auml': '\xc4',
177 'auml': '\xe4',
178 'Auml;': '\xc4',
179 'auml;': '\xe4',
180 'awconint;': '\u2233',
181 'awint;': '\u2a11',
182 'backcong;': '\u224c',
183 'backepsilon;': '\u03f6',
184 'backprime;': '\u2035',
185 'backsim;': '\u223d',
186 'backsimeq;': '\u22cd',
187 'Backslash;': '\u2216',
188 'Barv;': '\u2ae7',
189 'barvee;': '\u22bd',
190 'Barwed;': '\u2306',
191 'barwed;': '\u2305',
192 'barwedge;': '\u2305',
193 'bbrk;': '\u23b5',
194 'bbrktbrk;': '\u23b6',
195 'bcong;': '\u224c',
196 'Bcy;': '\u0411',
197 'bcy;': '\u0431',
198 'bdquo;': '\u201e',
199 'becaus;': '\u2235',
200 'Because;': '\u2235',
201 'because;': '\u2235',
202 'bemptyv;': '\u29b0',
203 'bepsi;': '\u03f6',
204 'bernou;': '\u212c',
205 'Bernoullis;': '\u212c',
206 'Beta;': '\u0392',
207 'beta;': '\u03b2',
208 'beth;': '\u2136',
209 'between;': '\u226c',
210 'Bfr;': '\U0001d505',
211 'bfr;': '\U0001d51f',
212 'bigcap;': '\u22c2',
213 'bigcirc;': '\u25ef',
214 'bigcup;': '\u22c3',
215 'bigodot;': '\u2a00',
216 'bigoplus;': '\u2a01',
217 'bigotimes;': '\u2a02',
218 'bigsqcup;': '\u2a06',
219 'bigstar;': '\u2605',
220 'bigtriangledown;': '\u25bd',
221 'bigtriangleup;': '\u25b3',
222 'biguplus;': '\u2a04',
223 'bigvee;': '\u22c1',
224 'bigwedge;': '\u22c0',
225 'bkarow;': '\u290d',
226 'blacklozenge;': '\u29eb',
227 'blacksquare;': '\u25aa',
228 'blacktriangle;': '\u25b4',
229 'blacktriangledown;': '\u25be',
230 'blacktriangleleft;': '\u25c2',
231 'blacktriangleright;': '\u25b8',
232 'blank;': '\u2423',
233 'blk12;': '\u2592',
234 'blk14;': '\u2591',
235 'blk34;': '\u2593',
236 'block;': '\u2588',
237 'bne;': '=\u20e5',
238 'bnequiv;': '\u2261\u20e5',
239 'bNot;': '\u2aed',
240 'bnot;': '\u2310',
241 'Bopf;': '\U0001d539',
242 'bopf;': '\U0001d553',
243 'bot;': '\u22a5',
244 'bottom;': '\u22a5',
245 'bowtie;': '\u22c8',
246 'boxbox;': '\u29c9',
247 'boxDL;': '\u2557',
248 'boxDl;': '\u2556',
249 'boxdL;': '\u2555',
250 'boxdl;': '\u2510',
251 'boxDR;': '\u2554',
252 'boxDr;': '\u2553',
253 'boxdR;': '\u2552',
254 'boxdr;': '\u250c',
255 'boxH;': '\u2550',
256 'boxh;': '\u2500',
257 'boxHD;': '\u2566',
258 'boxHd;': '\u2564',
259 'boxhD;': '\u2565',
260 'boxhd;': '\u252c',
261 'boxHU;': '\u2569',
262 'boxHu;': '\u2567',
263 'boxhU;': '\u2568',
264 'boxhu;': '\u2534',
265 'boxminus;': '\u229f',
266 'boxplus;': '\u229e',
267 'boxtimes;': '\u22a0',
268 'boxUL;': '\u255d',
269 'boxUl;': '\u255c',
270 'boxuL;': '\u255b',
271 'boxul;': '\u2518',
272 'boxUR;': '\u255a',
273 'boxUr;': '\u2559',
274 'boxuR;': '\u2558',
275 'boxur;': '\u2514',
276 'boxV;': '\u2551',
277 'boxv;': '\u2502',
278 'boxVH;': '\u256c',
279 'boxVh;': '\u256b',
280 'boxvH;': '\u256a',
281 'boxvh;': '\u253c',
282 'boxVL;': '\u2563',
283 'boxVl;': '\u2562',
284 'boxvL;': '\u2561',
285 'boxvl;': '\u2524',
286 'boxVR;': '\u2560',
287 'boxVr;': '\u255f',
288 'boxvR;': '\u255e',
289 'boxvr;': '\u251c',
290 'bprime;': '\u2035',
291 'Breve;': '\u02d8',
292 'breve;': '\u02d8',
293 'brvbar': '\xa6',
294 'brvbar;': '\xa6',
295 'Bscr;': '\u212c',
296 'bscr;': '\U0001d4b7',
297 'bsemi;': '\u204f',
298 'bsim;': '\u223d',
299 'bsime;': '\u22cd',
300 'bsol;': '\\',
301 'bsolb;': '\u29c5',
302 'bsolhsub;': '\u27c8',
303 'bull;': '\u2022',
304 'bullet;': '\u2022',
305 'bump;': '\u224e',
306 'bumpE;': '\u2aae',
307 'bumpe;': '\u224f',
308 'Bumpeq;': '\u224e',
309 'bumpeq;': '\u224f',
310 'Cacute;': '\u0106',
311 'cacute;': '\u0107',
312 'Cap;': '\u22d2',
313 'cap;': '\u2229',
314 'capand;': '\u2a44',
315 'capbrcup;': '\u2a49',
316 'capcap;': '\u2a4b',
317 'capcup;': '\u2a47',
318 'capdot;': '\u2a40',
319 'CapitalDifferentialD;': '\u2145',
320 'caps;': '\u2229\ufe00',
321 'caret;': '\u2041',
322 'caron;': '\u02c7',
323 'Cayleys;': '\u212d',
324 'ccaps;': '\u2a4d',
325 'Ccaron;': '\u010c',
326 'ccaron;': '\u010d',
327 'Ccedil': '\xc7',
328 'ccedil': '\xe7',
329 'Ccedil;': '\xc7',
330 'ccedil;': '\xe7',
331 'Ccirc;': '\u0108',
332 'ccirc;': '\u0109',
333 'Cconint;': '\u2230',
334 'ccups;': '\u2a4c',
335 'ccupssm;': '\u2a50',
336 'Cdot;': '\u010a',
337 'cdot;': '\u010b',
338 'cedil': '\xb8',
339 'cedil;': '\xb8',
340 'Cedilla;': '\xb8',
341 'cemptyv;': '\u29b2',
342 'cent': '\xa2',
343 'cent;': '\xa2',
344 'CenterDot;': '\xb7',
345 'centerdot;': '\xb7',
346 'Cfr;': '\u212d',
347 'cfr;': '\U0001d520',
348 'CHcy;': '\u0427',
349 'chcy;': '\u0447',
350 'check;': '\u2713',
351 'checkmark;': '\u2713',
352 'Chi;': '\u03a7',
353 'chi;': '\u03c7',
354 'cir;': '\u25cb',
355 'circ;': '\u02c6',
356 'circeq;': '\u2257',
357 'circlearrowleft;': '\u21ba',
358 'circlearrowright;': '\u21bb',
359 'circledast;': '\u229b',
360 'circledcirc;': '\u229a',
361 'circleddash;': '\u229d',
362 'CircleDot;': '\u2299',
363 'circledR;': '\xae',
364 'circledS;': '\u24c8',
365 'CircleMinus;': '\u2296',
366 'CirclePlus;': '\u2295',
367 'CircleTimes;': '\u2297',
368 'cirE;': '\u29c3',
369 'cire;': '\u2257',
370 'cirfnint;': '\u2a10',
371 'cirmid;': '\u2aef',
372 'cirscir;': '\u29c2',
373 'ClockwiseContourIntegral;': '\u2232',
374 'CloseCurlyDoubleQuote;': '\u201d',
375 'CloseCurlyQuote;': '\u2019',
376 'clubs;': '\u2663',
377 'clubsuit;': '\u2663',
378 'Colon;': '\u2237',
379 'colon;': ':',
380 'Colone;': '\u2a74',
381 'colone;': '\u2254',
382 'coloneq;': '\u2254',
383 'comma;': ',',
384 'commat;': '@',
385 'comp;': '\u2201',
386 'compfn;': '\u2218',
387 'complement;': '\u2201',
388 'complexes;': '\u2102',
389 'cong;': '\u2245',
390 'congdot;': '\u2a6d',
391 'Congruent;': '\u2261',
392 'Conint;': '\u222f',
393 'conint;': '\u222e',
394 'ContourIntegral;': '\u222e',
395 'Copf;': '\u2102',
396 'copf;': '\U0001d554',
397 'coprod;': '\u2210',
398 'Coproduct;': '\u2210',
399 'COPY': '\xa9',
400 'copy': '\xa9',
401 'COPY;': '\xa9',
402 'copy;': '\xa9',
403 'copysr;': '\u2117',
404 'CounterClockwiseContourIntegral;': '\u2233',
405 'crarr;': '\u21b5',
406 'Cross;': '\u2a2f',
407 'cross;': '\u2717',
408 'Cscr;': '\U0001d49e',
409 'cscr;': '\U0001d4b8',
410 'csub;': '\u2acf',
411 'csube;': '\u2ad1',
412 'csup;': '\u2ad0',
413 'csupe;': '\u2ad2',
414 'ctdot;': '\u22ef',
415 'cudarrl;': '\u2938',
416 'cudarrr;': '\u2935',
417 'cuepr;': '\u22de',
418 'cuesc;': '\u22df',
419 'cularr;': '\u21b6',
420 'cularrp;': '\u293d',
421 'Cup;': '\u22d3',
422 'cup;': '\u222a',
423 'cupbrcap;': '\u2a48',
424 'CupCap;': '\u224d',
425 'cupcap;': '\u2a46',
426 'cupcup;': '\u2a4a',
427 'cupdot;': '\u228d',
428 'cupor;': '\u2a45',
429 'cups;': '\u222a\ufe00',
430 'curarr;': '\u21b7',
431 'curarrm;': '\u293c',
432 'curlyeqprec;': '\u22de',
433 'curlyeqsucc;': '\u22df',
434 'curlyvee;': '\u22ce',
435 'curlywedge;': '\u22cf',
436 'curren': '\xa4',
437 'curren;': '\xa4',
438 'curvearrowleft;': '\u21b6',
439 'curvearrowright;': '\u21b7',
440 'cuvee;': '\u22ce',
441 'cuwed;': '\u22cf',
442 'cwconint;': '\u2232',
443 'cwint;': '\u2231',
444 'cylcty;': '\u232d',
445 'Dagger;': '\u2021',
446 'dagger;': '\u2020',
447 'daleth;': '\u2138',
448 'Darr;': '\u21a1',
449 'dArr;': '\u21d3',
450 'darr;': '\u2193',
451 'dash;': '\u2010',
452 'Dashv;': '\u2ae4',
453 'dashv;': '\u22a3',
454 'dbkarow;': '\u290f',
455 'dblac;': '\u02dd',
456 'Dcaron;': '\u010e',
457 'dcaron;': '\u010f',
458 'Dcy;': '\u0414',
459 'dcy;': '\u0434',
460 'DD;': '\u2145',
461 'dd;': '\u2146',
462 'ddagger;': '\u2021',
463 'ddarr;': '\u21ca',
464 'DDotrahd;': '\u2911',
465 'ddotseq;': '\u2a77',
466 'deg': '\xb0',
467 'deg;': '\xb0',
468 'Del;': '\u2207',
469 'Delta;': '\u0394',
470 'delta;': '\u03b4',
471 'demptyv;': '\u29b1',
472 'dfisht;': '\u297f',
473 'Dfr;': '\U0001d507',
474 'dfr;': '\U0001d521',
475 'dHar;': '\u2965',
476 'dharl;': '\u21c3',
477 'dharr;': '\u21c2',
478 'DiacriticalAcute;': '\xb4',
479 'DiacriticalDot;': '\u02d9',
480 'DiacriticalDoubleAcute;': '\u02dd',
481 'DiacriticalGrave;': '`',
482 'DiacriticalTilde;': '\u02dc',
483 'diam;': '\u22c4',
484 'Diamond;': '\u22c4',
485 'diamond;': '\u22c4',
486 'diamondsuit;': '\u2666',
487 'diams;': '\u2666',
488 'die;': '\xa8',
489 'DifferentialD;': '\u2146',
490 'digamma;': '\u03dd',
491 'disin;': '\u22f2',
492 'div;': '\xf7',
493 'divide': '\xf7',
494 'divide;': '\xf7',
495 'divideontimes;': '\u22c7',
496 'divonx;': '\u22c7',
497 'DJcy;': '\u0402',
498 'djcy;': '\u0452',
499 'dlcorn;': '\u231e',
500 'dlcrop;': '\u230d',
501 'dollar;': '$',
502 'Dopf;': '\U0001d53b',
503 'dopf;': '\U0001d555',
504 'Dot;': '\xa8',
505 'dot;': '\u02d9',
506 'DotDot;': '\u20dc',
507 'doteq;': '\u2250',
508 'doteqdot;': '\u2251',
509 'DotEqual;': '\u2250',
510 'dotminus;': '\u2238',
511 'dotplus;': '\u2214',
512 'dotsquare;': '\u22a1',
513 'doublebarwedge;': '\u2306',
514 'DoubleContourIntegral;': '\u222f',
515 'DoubleDot;': '\xa8',
516 'DoubleDownArrow;': '\u21d3',
517 'DoubleLeftArrow;': '\u21d0',
518 'DoubleLeftRightArrow;': '\u21d4',
519 'DoubleLeftTee;': '\u2ae4',
520 'DoubleLongLeftArrow;': '\u27f8',
521 'DoubleLongLeftRightArrow;': '\u27fa',
522 'DoubleLongRightArrow;': '\u27f9',
523 'DoubleRightArrow;': '\u21d2',
524 'DoubleRightTee;': '\u22a8',
525 'DoubleUpArrow;': '\u21d1',
526 'DoubleUpDownArrow;': '\u21d5',
527 'DoubleVerticalBar;': '\u2225',
528 'DownArrow;': '\u2193',
529 'Downarrow;': '\u21d3',
530 'downarrow;': '\u2193',
531 'DownArrowBar;': '\u2913',
532 'DownArrowUpArrow;': '\u21f5',
533 'DownBreve;': '\u0311',
534 'downdownarrows;': '\u21ca',
535 'downharpoonleft;': '\u21c3',
536 'downharpoonright;': '\u21c2',
537 'DownLeftRightVector;': '\u2950',
538 'DownLeftTeeVector;': '\u295e',
539 'DownLeftVector;': '\u21bd',
540 'DownLeftVectorBar;': '\u2956',
541 'DownRightTeeVector;': '\u295f',
542 'DownRightVector;': '\u21c1',
543 'DownRightVectorBar;': '\u2957',
544 'DownTee;': '\u22a4',
545 'DownTeeArrow;': '\u21a7',
546 'drbkarow;': '\u2910',
547 'drcorn;': '\u231f',
548 'drcrop;': '\u230c',
549 'Dscr;': '\U0001d49f',
550 'dscr;': '\U0001d4b9',
551 'DScy;': '\u0405',
552 'dscy;': '\u0455',
553 'dsol;': '\u29f6',
554 'Dstrok;': '\u0110',
555 'dstrok;': '\u0111',
556 'dtdot;': '\u22f1',
557 'dtri;': '\u25bf',
558 'dtrif;': '\u25be',
559 'duarr;': '\u21f5',
560 'duhar;': '\u296f',
561 'dwangle;': '\u29a6',
562 'DZcy;': '\u040f',
563 'dzcy;': '\u045f',
564 'dzigrarr;': '\u27ff',
565 'Eacute': '\xc9',
566 'eacute': '\xe9',
567 'Eacute;': '\xc9',
568 'eacute;': '\xe9',
569 'easter;': '\u2a6e',
570 'Ecaron;': '\u011a',
571 'ecaron;': '\u011b',
572 'ecir;': '\u2256',
573 'Ecirc': '\xca',
574 'ecirc': '\xea',
575 'Ecirc;': '\xca',
576 'ecirc;': '\xea',
577 'ecolon;': '\u2255',
578 'Ecy;': '\u042d',
579 'ecy;': '\u044d',
580 'eDDot;': '\u2a77',
581 'Edot;': '\u0116',
582 'eDot;': '\u2251',
583 'edot;': '\u0117',
584 'ee;': '\u2147',
585 'efDot;': '\u2252',
586 'Efr;': '\U0001d508',
587 'efr;': '\U0001d522',
588 'eg;': '\u2a9a',
589 'Egrave': '\xc8',
590 'egrave': '\xe8',
591 'Egrave;': '\xc8',
592 'egrave;': '\xe8',
593 'egs;': '\u2a96',
594 'egsdot;': '\u2a98',
595 'el;': '\u2a99',
596 'Element;': '\u2208',
597 'elinters;': '\u23e7',
598 'ell;': '\u2113',
599 'els;': '\u2a95',
600 'elsdot;': '\u2a97',
601 'Emacr;': '\u0112',
602 'emacr;': '\u0113',
603 'empty;': '\u2205',
604 'emptyset;': '\u2205',
605 'EmptySmallSquare;': '\u25fb',
606 'emptyv;': '\u2205',
607 'EmptyVerySmallSquare;': '\u25ab',
608 'emsp13;': '\u2004',
609 'emsp14;': '\u2005',
610 'emsp;': '\u2003',
611 'ENG;': '\u014a',
612 'eng;': '\u014b',
613 'ensp;': '\u2002',
614 'Eogon;': '\u0118',
615 'eogon;': '\u0119',
616 'Eopf;': '\U0001d53c',
617 'eopf;': '\U0001d556',
618 'epar;': '\u22d5',
619 'eparsl;': '\u29e3',
620 'eplus;': '\u2a71',
621 'epsi;': '\u03b5',
622 'Epsilon;': '\u0395',
623 'epsilon;': '\u03b5',
624 'epsiv;': '\u03f5',
625 'eqcirc;': '\u2256',
626 'eqcolon;': '\u2255',
627 'eqsim;': '\u2242',
628 'eqslantgtr;': '\u2a96',
629 'eqslantless;': '\u2a95',
630 'Equal;': '\u2a75',
631 'equals;': '=',
632 'EqualTilde;': '\u2242',
633 'equest;': '\u225f',
634 'Equilibrium;': '\u21cc',
635 'equiv;': '\u2261',
636 'equivDD;': '\u2a78',
637 'eqvparsl;': '\u29e5',
638 'erarr;': '\u2971',
639 'erDot;': '\u2253',
640 'Escr;': '\u2130',
641 'escr;': '\u212f',
642 'esdot;': '\u2250',
643 'Esim;': '\u2a73',
644 'esim;': '\u2242',
645 'Eta;': '\u0397',
646 'eta;': '\u03b7',
647 'ETH': '\xd0',
648 'eth': '\xf0',
649 'ETH;': '\xd0',
650 'eth;': '\xf0',
651 'Euml': '\xcb',
652 'euml': '\xeb',
653 'Euml;': '\xcb',
654 'euml;': '\xeb',
655 'euro;': '\u20ac',
656 'excl;': '!',
657 'exist;': '\u2203',
658 'Exists;': '\u2203',
659 'expectation;': '\u2130',
660 'ExponentialE;': '\u2147',
661 'exponentiale;': '\u2147',
662 'fallingdotseq;': '\u2252',
663 'Fcy;': '\u0424',
664 'fcy;': '\u0444',
665 'female;': '\u2640',
666 'ffilig;': '\ufb03',
667 'fflig;': '\ufb00',
668 'ffllig;': '\ufb04',
669 'Ffr;': '\U0001d509',
670 'ffr;': '\U0001d523',
671 'filig;': '\ufb01',
672 'FilledSmallSquare;': '\u25fc',
673 'FilledVerySmallSquare;': '\u25aa',
674 'fjlig;': 'fj',
675 'flat;': '\u266d',
676 'fllig;': '\ufb02',
677 'fltns;': '\u25b1',
678 'fnof;': '\u0192',
679 'Fopf;': '\U0001d53d',
680 'fopf;': '\U0001d557',
681 'ForAll;': '\u2200',
682 'forall;': '\u2200',
683 'fork;': '\u22d4',
684 'forkv;': '\u2ad9',
685 'Fouriertrf;': '\u2131',
686 'fpartint;': '\u2a0d',
687 'frac12': '\xbd',
688 'frac12;': '\xbd',
689 'frac13;': '\u2153',
690 'frac14': '\xbc',
691 'frac14;': '\xbc',
692 'frac15;': '\u2155',
693 'frac16;': '\u2159',
694 'frac18;': '\u215b',
695 'frac23;': '\u2154',
696 'frac25;': '\u2156',
697 'frac34': '\xbe',
698 'frac34;': '\xbe',
699 'frac35;': '\u2157',
700 'frac38;': '\u215c',
701 'frac45;': '\u2158',
702 'frac56;': '\u215a',
703 'frac58;': '\u215d',
704 'frac78;': '\u215e',
705 'frasl;': '\u2044',
706 'frown;': '\u2322',
707 'Fscr;': '\u2131',
708 'fscr;': '\U0001d4bb',
709 'gacute;': '\u01f5',
710 'Gamma;': '\u0393',
711 'gamma;': '\u03b3',
712 'Gammad;': '\u03dc',
713 'gammad;': '\u03dd',
714 'gap;': '\u2a86',
715 'Gbreve;': '\u011e',
716 'gbreve;': '\u011f',
717 'Gcedil;': '\u0122',
718 'Gcirc;': '\u011c',
719 'gcirc;': '\u011d',
720 'Gcy;': '\u0413',
721 'gcy;': '\u0433',
722 'Gdot;': '\u0120',
723 'gdot;': '\u0121',
724 'gE;': '\u2267',
725 'ge;': '\u2265',
726 'gEl;': '\u2a8c',
727 'gel;': '\u22db',
728 'geq;': '\u2265',
729 'geqq;': '\u2267',
730 'geqslant;': '\u2a7e',
731 'ges;': '\u2a7e',
732 'gescc;': '\u2aa9',
733 'gesdot;': '\u2a80',
734 'gesdoto;': '\u2a82',
735 'gesdotol;': '\u2a84',
736 'gesl;': '\u22db\ufe00',
737 'gesles;': '\u2a94',
738 'Gfr;': '\U0001d50a',
739 'gfr;': '\U0001d524',
740 'Gg;': '\u22d9',
741 'gg;': '\u226b',
742 'ggg;': '\u22d9',
743 'gimel;': '\u2137',
744 'GJcy;': '\u0403',
745 'gjcy;': '\u0453',
746 'gl;': '\u2277',
747 'gla;': '\u2aa5',
748 'glE;': '\u2a92',
749 'glj;': '\u2aa4',
750 'gnap;': '\u2a8a',
751 'gnapprox;': '\u2a8a',
752 'gnE;': '\u2269',
753 'gne;': '\u2a88',
754 'gneq;': '\u2a88',
755 'gneqq;': '\u2269',
756 'gnsim;': '\u22e7',
757 'Gopf;': '\U0001d53e',
758 'gopf;': '\U0001d558',
759 'grave;': '`',
760 'GreaterEqual;': '\u2265',
761 'GreaterEqualLess;': '\u22db',
762 'GreaterFullEqual;': '\u2267',
763 'GreaterGreater;': '\u2aa2',
764 'GreaterLess;': '\u2277',
765 'GreaterSlantEqual;': '\u2a7e',
766 'GreaterTilde;': '\u2273',
767 'Gscr;': '\U0001d4a2',
768 'gscr;': '\u210a',
769 'gsim;': '\u2273',
770 'gsime;': '\u2a8e',
771 'gsiml;': '\u2a90',
772 'GT': '>',
773 'gt': '>',
774 'GT;': '>',
775 'Gt;': '\u226b',
776 'gt;': '>',
777 'gtcc;': '\u2aa7',
778 'gtcir;': '\u2a7a',
779 'gtdot;': '\u22d7',
780 'gtlPar;': '\u2995',
781 'gtquest;': '\u2a7c',
782 'gtrapprox;': '\u2a86',
783 'gtrarr;': '\u2978',
784 'gtrdot;': '\u22d7',
785 'gtreqless;': '\u22db',
786 'gtreqqless;': '\u2a8c',
787 'gtrless;': '\u2277',
788 'gtrsim;': '\u2273',
789 'gvertneqq;': '\u2269\ufe00',
790 'gvnE;': '\u2269\ufe00',
791 'Hacek;': '\u02c7',
792 'hairsp;': '\u200a',
793 'half;': '\xbd',
794 'hamilt;': '\u210b',
795 'HARDcy;': '\u042a',
796 'hardcy;': '\u044a',
797 'hArr;': '\u21d4',
798 'harr;': '\u2194',
799 'harrcir;': '\u2948',
800 'harrw;': '\u21ad',
801 'Hat;': '^',
802 'hbar;': '\u210f',
803 'Hcirc;': '\u0124',
804 'hcirc;': '\u0125',
805 'hearts;': '\u2665',
806 'heartsuit;': '\u2665',
807 'hellip;': '\u2026',
808 'hercon;': '\u22b9',
809 'Hfr;': '\u210c',
810 'hfr;': '\U0001d525',
811 'HilbertSpace;': '\u210b',
812 'hksearow;': '\u2925',
813 'hkswarow;': '\u2926',
814 'hoarr;': '\u21ff',
815 'homtht;': '\u223b',
816 'hookleftarrow;': '\u21a9',
817 'hookrightarrow;': '\u21aa',
818 'Hopf;': '\u210d',
819 'hopf;': '\U0001d559',
820 'horbar;': '\u2015',
821 'HorizontalLine;': '\u2500',
822 'Hscr;': '\u210b',
823 'hscr;': '\U0001d4bd',
824 'hslash;': '\u210f',
825 'Hstrok;': '\u0126',
826 'hstrok;': '\u0127',
827 'HumpDownHump;': '\u224e',
828 'HumpEqual;': '\u224f',
829 'hybull;': '\u2043',
830 'hyphen;': '\u2010',
831 'Iacute': '\xcd',
832 'iacute': '\xed',
833 'Iacute;': '\xcd',
834 'iacute;': '\xed',
835 'ic;': '\u2063',
836 'Icirc': '\xce',
837 'icirc': '\xee',
838 'Icirc;': '\xce',
839 'icirc;': '\xee',
840 'Icy;': '\u0418',
841 'icy;': '\u0438',
842 'Idot;': '\u0130',
843 'IEcy;': '\u0415',
844 'iecy;': '\u0435',
845 'iexcl': '\xa1',
846 'iexcl;': '\xa1',
847 'iff;': '\u21d4',
848 'Ifr;': '\u2111',
849 'ifr;': '\U0001d526',
850 'Igrave': '\xcc',
851 'igrave': '\xec',
852 'Igrave;': '\xcc',
853 'igrave;': '\xec',
854 'ii;': '\u2148',
855 'iiiint;': '\u2a0c',
856 'iiint;': '\u222d',
857 'iinfin;': '\u29dc',
858 'iiota;': '\u2129',
859 'IJlig;': '\u0132',
860 'ijlig;': '\u0133',
861 'Im;': '\u2111',
862 'Imacr;': '\u012a',
863 'imacr;': '\u012b',
864 'image;': '\u2111',
865 'ImaginaryI;': '\u2148',
866 'imagline;': '\u2110',
867 'imagpart;': '\u2111',
868 'imath;': '\u0131',
869 'imof;': '\u22b7',
870 'imped;': '\u01b5',
871 'Implies;': '\u21d2',
872 'in;': '\u2208',
873 'incare;': '\u2105',
874 'infin;': '\u221e',
875 'infintie;': '\u29dd',
876 'inodot;': '\u0131',
877 'Int;': '\u222c',
878 'int;': '\u222b',
879 'intcal;': '\u22ba',
880 'integers;': '\u2124',
881 'Integral;': '\u222b',
882 'intercal;': '\u22ba',
883 'Intersection;': '\u22c2',
884 'intlarhk;': '\u2a17',
885 'intprod;': '\u2a3c',
886 'InvisibleComma;': '\u2063',
887 'InvisibleTimes;': '\u2062',
888 'IOcy;': '\u0401',
889 'iocy;': '\u0451',
890 'Iogon;': '\u012e',
891 'iogon;': '\u012f',
892 'Iopf;': '\U0001d540',
893 'iopf;': '\U0001d55a',
894 'Iota;': '\u0399',
895 'iota;': '\u03b9',
896 'iprod;': '\u2a3c',
897 'iquest': '\xbf',
898 'iquest;': '\xbf',
899 'Iscr;': '\u2110',
900 'iscr;': '\U0001d4be',
901 'isin;': '\u2208',
902 'isindot;': '\u22f5',
903 'isinE;': '\u22f9',
904 'isins;': '\u22f4',
905 'isinsv;': '\u22f3',
906 'isinv;': '\u2208',
907 'it;': '\u2062',
908 'Itilde;': '\u0128',
909 'itilde;': '\u0129',
910 'Iukcy;': '\u0406',
911 'iukcy;': '\u0456',
912 'Iuml': '\xcf',
913 'iuml': '\xef',
914 'Iuml;': '\xcf',
915 'iuml;': '\xef',
916 'Jcirc;': '\u0134',
917 'jcirc;': '\u0135',
918 'Jcy;': '\u0419',
919 'jcy;': '\u0439',
920 'Jfr;': '\U0001d50d',
921 'jfr;': '\U0001d527',
922 'jmath;': '\u0237',
923 'Jopf;': '\U0001d541',
924 'jopf;': '\U0001d55b',
925 'Jscr;': '\U0001d4a5',
926 'jscr;': '\U0001d4bf',
927 'Jsercy;': '\u0408',
928 'jsercy;': '\u0458',
929 'Jukcy;': '\u0404',
930 'jukcy;': '\u0454',
931 'Kappa;': '\u039a',
932 'kappa;': '\u03ba',
933 'kappav;': '\u03f0',
934 'Kcedil;': '\u0136',
935 'kcedil;': '\u0137',
936 'Kcy;': '\u041a',
937 'kcy;': '\u043a',
938 'Kfr;': '\U0001d50e',
939 'kfr;': '\U0001d528',
940 'kgreen;': '\u0138',
941 'KHcy;': '\u0425',
942 'khcy;': '\u0445',
943 'KJcy;': '\u040c',
944 'kjcy;': '\u045c',
945 'Kopf;': '\U0001d542',
946 'kopf;': '\U0001d55c',
947 'Kscr;': '\U0001d4a6',
948 'kscr;': '\U0001d4c0',
949 'lAarr;': '\u21da',
950 'Lacute;': '\u0139',
951 'lacute;': '\u013a',
952 'laemptyv;': '\u29b4',
953 'lagran;': '\u2112',
954 'Lambda;': '\u039b',
955 'lambda;': '\u03bb',
956 'Lang;': '\u27ea',
957 'lang;': '\u27e8',
958 'langd;': '\u2991',
959 'langle;': '\u27e8',
960 'lap;': '\u2a85',
961 'Laplacetrf;': '\u2112',
962 'laquo': '\xab',
963 'laquo;': '\xab',
964 'Larr;': '\u219e',
965 'lArr;': '\u21d0',
966 'larr;': '\u2190',
967 'larrb;': '\u21e4',
968 'larrbfs;': '\u291f',
969 'larrfs;': '\u291d',
970 'larrhk;': '\u21a9',
971 'larrlp;': '\u21ab',
972 'larrpl;': '\u2939',
973 'larrsim;': '\u2973',
974 'larrtl;': '\u21a2',
975 'lat;': '\u2aab',
976 'lAtail;': '\u291b',
977 'latail;': '\u2919',
978 'late;': '\u2aad',
979 'lates;': '\u2aad\ufe00',
980 'lBarr;': '\u290e',
981 'lbarr;': '\u290c',
982 'lbbrk;': '\u2772',
983 'lbrace;': '{',
984 'lbrack;': '[',
985 'lbrke;': '\u298b',
986 'lbrksld;': '\u298f',
987 'lbrkslu;': '\u298d',
988 'Lcaron;': '\u013d',
989 'lcaron;': '\u013e',
990 'Lcedil;': '\u013b',
991 'lcedil;': '\u013c',
992 'lceil;': '\u2308',
993 'lcub;': '{',
994 'Lcy;': '\u041b',
995 'lcy;': '\u043b',
996 'ldca;': '\u2936',
997 'ldquo;': '\u201c',
998 'ldquor;': '\u201e',
999 'ldrdhar;': '\u2967',
1000 'ldrushar;': '\u294b',
1001 'ldsh;': '\u21b2',
1002 'lE;': '\u2266',
1003 'le;': '\u2264',
1004 'LeftAngleBracket;': '\u27e8',
1005 'LeftArrow;': '\u2190',
1006 'Leftarrow;': '\u21d0',
1007 'leftarrow;': '\u2190',
1008 'LeftArrowBar;': '\u21e4',
1009 'LeftArrowRightArrow;': '\u21c6',
1010 'leftarrowtail;': '\u21a2',
1011 'LeftCeiling;': '\u2308',
1012 'LeftDoubleBracket;': '\u27e6',
1013 'LeftDownTeeVector;': '\u2961',
1014 'LeftDownVector;': '\u21c3',
1015 'LeftDownVectorBar;': '\u2959',
1016 'LeftFloor;': '\u230a',
1017 'leftharpoondown;': '\u21bd',
1018 'leftharpoonup;': '\u21bc',
1019 'leftleftarrows;': '\u21c7',
1020 'LeftRightArrow;': '\u2194',
1021 'Leftrightarrow;': '\u21d4',
1022 'leftrightarrow;': '\u2194',
1023 'leftrightarrows;': '\u21c6',
1024 'leftrightharpoons;': '\u21cb',
1025 'leftrightsquigarrow;': '\u21ad',
1026 'LeftRightVector;': '\u294e',
1027 'LeftTee;': '\u22a3',
1028 'LeftTeeArrow;': '\u21a4',
1029 'LeftTeeVector;': '\u295a',
1030 'leftthreetimes;': '\u22cb',
1031 'LeftTriangle;': '\u22b2',
1032 'LeftTriangleBar;': '\u29cf',
1033 'LeftTriangleEqual;': '\u22b4',
1034 'LeftUpDownVector;': '\u2951',
1035 'LeftUpTeeVector;': '\u2960',
1036 'LeftUpVector;': '\u21bf',
1037 'LeftUpVectorBar;': '\u2958',
1038 'LeftVector;': '\u21bc',
1039 'LeftVectorBar;': '\u2952',
1040 'lEg;': '\u2a8b',
1041 'leg;': '\u22da',
1042 'leq;': '\u2264',
1043 'leqq;': '\u2266',
1044 'leqslant;': '\u2a7d',
1045 'les;': '\u2a7d',
1046 'lescc;': '\u2aa8',
1047 'lesdot;': '\u2a7f',
1048 'lesdoto;': '\u2a81',
1049 'lesdotor;': '\u2a83',
1050 'lesg;': '\u22da\ufe00',
1051 'lesges;': '\u2a93',
1052 'lessapprox;': '\u2a85',
1053 'lessdot;': '\u22d6',
1054 'lesseqgtr;': '\u22da',
1055 'lesseqqgtr;': '\u2a8b',
1056 'LessEqualGreater;': '\u22da',
1057 'LessFullEqual;': '\u2266',
1058 'LessGreater;': '\u2276',
1059 'lessgtr;': '\u2276',
1060 'LessLess;': '\u2aa1',
1061 'lesssim;': '\u2272',
1062 'LessSlantEqual;': '\u2a7d',
1063 'LessTilde;': '\u2272',
1064 'lfisht;': '\u297c',
1065 'lfloor;': '\u230a',
1066 'Lfr;': '\U0001d50f',
1067 'lfr;': '\U0001d529',
1068 'lg;': '\u2276',
1069 'lgE;': '\u2a91',
1070 'lHar;': '\u2962',
1071 'lhard;': '\u21bd',
1072 'lharu;': '\u21bc',
1073 'lharul;': '\u296a',
1074 'lhblk;': '\u2584',
1075 'LJcy;': '\u0409',
1076 'ljcy;': '\u0459',
1077 'Ll;': '\u22d8',
1078 'll;': '\u226a',
1079 'llarr;': '\u21c7',
1080 'llcorner;': '\u231e',
1081 'Lleftarrow;': '\u21da',
1082 'llhard;': '\u296b',
1083 'lltri;': '\u25fa',
1084 'Lmidot;': '\u013f',
1085 'lmidot;': '\u0140',
1086 'lmoust;': '\u23b0',
1087 'lmoustache;': '\u23b0',
1088 'lnap;': '\u2a89',
1089 'lnapprox;': '\u2a89',
1090 'lnE;': '\u2268',
1091 'lne;': '\u2a87',
1092 'lneq;': '\u2a87',
1093 'lneqq;': '\u2268',
1094 'lnsim;': '\u22e6',
1095 'loang;': '\u27ec',
1096 'loarr;': '\u21fd',
1097 'lobrk;': '\u27e6',
1098 'LongLeftArrow;': '\u27f5',
1099 'Longleftarrow;': '\u27f8',
1100 'longleftarrow;': '\u27f5',
1101 'LongLeftRightArrow;': '\u27f7',
1102 'Longleftrightarrow;': '\u27fa',
1103 'longleftrightarrow;': '\u27f7',
1104 'longmapsto;': '\u27fc',
1105 'LongRightArrow;': '\u27f6',
1106 'Longrightarrow;': '\u27f9',
1107 'longrightarrow;': '\u27f6',
1108 'looparrowleft;': '\u21ab',
1109 'looparrowright;': '\u21ac',
1110 'lopar;': '\u2985',
1111 'Lopf;': '\U0001d543',
1112 'lopf;': '\U0001d55d',
1113 'loplus;': '\u2a2d',
1114 'lotimes;': '\u2a34',
1115 'lowast;': '\u2217',
1116 'lowbar;': '_',
1117 'LowerLeftArrow;': '\u2199',
1118 'LowerRightArrow;': '\u2198',
1119 'loz;': '\u25ca',
1120 'lozenge;': '\u25ca',
1121 'lozf;': '\u29eb',
1122 'lpar;': '(',
1123 'lparlt;': '\u2993',
1124 'lrarr;': '\u21c6',
1125 'lrcorner;': '\u231f',
1126 'lrhar;': '\u21cb',
1127 'lrhard;': '\u296d',
1128 'lrm;': '\u200e',
1129 'lrtri;': '\u22bf',
1130 'lsaquo;': '\u2039',
1131 'Lscr;': '\u2112',
1132 'lscr;': '\U0001d4c1',
1133 'Lsh;': '\u21b0',
1134 'lsh;': '\u21b0',
1135 'lsim;': '\u2272',
1136 'lsime;': '\u2a8d',
1137 'lsimg;': '\u2a8f',
1138 'lsqb;': '[',
1139 'lsquo;': '\u2018',
1140 'lsquor;': '\u201a',
1141 'Lstrok;': '\u0141',
1142 'lstrok;': '\u0142',
1143 'LT': '<',
1144 'lt': '<',
1145 'LT;': '<',
1146 'Lt;': '\u226a',
1147 'lt;': '<',
1148 'ltcc;': '\u2aa6',
1149 'ltcir;': '\u2a79',
1150 'ltdot;': '\u22d6',
1151 'lthree;': '\u22cb',
1152 'ltimes;': '\u22c9',
1153 'ltlarr;': '\u2976',
1154 'ltquest;': '\u2a7b',
1155 'ltri;': '\u25c3',
1156 'ltrie;': '\u22b4',
1157 'ltrif;': '\u25c2',
1158 'ltrPar;': '\u2996',
1159 'lurdshar;': '\u294a',
1160 'luruhar;': '\u2966',
1161 'lvertneqq;': '\u2268\ufe00',
1162 'lvnE;': '\u2268\ufe00',
1163 'macr': '\xaf',
1164 'macr;': '\xaf',
1165 'male;': '\u2642',
1166 'malt;': '\u2720',
1167 'maltese;': '\u2720',
1168 'Map;': '\u2905',
1169 'map;': '\u21a6',
1170 'mapsto;': '\u21a6',
1171 'mapstodown;': '\u21a7',
1172 'mapstoleft;': '\u21a4',
1173 'mapstoup;': '\u21a5',
1174 'marker;': '\u25ae',
1175 'mcomma;': '\u2a29',
1176 'Mcy;': '\u041c',
1177 'mcy;': '\u043c',
1178 'mdash;': '\u2014',
1179 'mDDot;': '\u223a',
1180 'measuredangle;': '\u2221',
1181 'MediumSpace;': '\u205f',
1182 'Mellintrf;': '\u2133',
1183 'Mfr;': '\U0001d510',
1184 'mfr;': '\U0001d52a',
1185 'mho;': '\u2127',
1186 'micro': '\xb5',
1187 'micro;': '\xb5',
1188 'mid;': '\u2223',
1189 'midast;': '*',
1190 'midcir;': '\u2af0',
1191 'middot': '\xb7',
1192 'middot;': '\xb7',
1193 'minus;': '\u2212',
1194 'minusb;': '\u229f',
1195 'minusd;': '\u2238',
1196 'minusdu;': '\u2a2a',
1197 'MinusPlus;': '\u2213',
1198 'mlcp;': '\u2adb',
1199 'mldr;': '\u2026',
1200 'mnplus;': '\u2213',
1201 'models;': '\u22a7',
1202 'Mopf;': '\U0001d544',
1203 'mopf;': '\U0001d55e',
1204 'mp;': '\u2213',
1205 'Mscr;': '\u2133',
1206 'mscr;': '\U0001d4c2',
1207 'mstpos;': '\u223e',
1208 'Mu;': '\u039c',
1209 'mu;': '\u03bc',
1210 'multimap;': '\u22b8',
1211 'mumap;': '\u22b8',
1212 'nabla;': '\u2207',
1213 'Nacute;': '\u0143',
1214 'nacute;': '\u0144',
1215 'nang;': '\u2220\u20d2',
1216 'nap;': '\u2249',
1217 'napE;': '\u2a70\u0338',
1218 'napid;': '\u224b\u0338',
1219 'napos;': '\u0149',
1220 'napprox;': '\u2249',
1221 'natur;': '\u266e',
1222 'natural;': '\u266e',
1223 'naturals;': '\u2115',
1224 'nbsp': '\xa0',
1225 'nbsp;': '\xa0',
1226 'nbump;': '\u224e\u0338',
1227 'nbumpe;': '\u224f\u0338',
1228 'ncap;': '\u2a43',
1229 'Ncaron;': '\u0147',
1230 'ncaron;': '\u0148',
1231 'Ncedil;': '\u0145',
1232 'ncedil;': '\u0146',
1233 'ncong;': '\u2247',
1234 'ncongdot;': '\u2a6d\u0338',
1235 'ncup;': '\u2a42',
1236 'Ncy;': '\u041d',
1237 'ncy;': '\u043d',
1238 'ndash;': '\u2013',
1239 'ne;': '\u2260',
1240 'nearhk;': '\u2924',
1241 'neArr;': '\u21d7',
1242 'nearr;': '\u2197',
1243 'nearrow;': '\u2197',
1244 'nedot;': '\u2250\u0338',
1245 'NegativeMediumSpace;': '\u200b',
1246 'NegativeThickSpace;': '\u200b',
1247 'NegativeThinSpace;': '\u200b',
1248 'NegativeVeryThinSpace;': '\u200b',
1249 'nequiv;': '\u2262',
1250 'nesear;': '\u2928',
1251 'nesim;': '\u2242\u0338',
1252 'NestedGreaterGreater;': '\u226b',
1253 'NestedLessLess;': '\u226a',
1254 'NewLine;': '\n',
1255 'nexist;': '\u2204',
1256 'nexists;': '\u2204',
1257 'Nfr;': '\U0001d511',
1258 'nfr;': '\U0001d52b',
1259 'ngE;': '\u2267\u0338',
1260 'nge;': '\u2271',
1261 'ngeq;': '\u2271',
1262 'ngeqq;': '\u2267\u0338',
1263 'ngeqslant;': '\u2a7e\u0338',
1264 'nges;': '\u2a7e\u0338',
1265 'nGg;': '\u22d9\u0338',
1266 'ngsim;': '\u2275',
1267 'nGt;': '\u226b\u20d2',
1268 'ngt;': '\u226f',
1269 'ngtr;': '\u226f',
1270 'nGtv;': '\u226b\u0338',
1271 'nhArr;': '\u21ce',
1272 'nharr;': '\u21ae',
1273 'nhpar;': '\u2af2',
1274 'ni;': '\u220b',
1275 'nis;': '\u22fc',
1276 'nisd;': '\u22fa',
1277 'niv;': '\u220b',
1278 'NJcy;': '\u040a',
1279 'njcy;': '\u045a',
1280 'nlArr;': '\u21cd',
1281 'nlarr;': '\u219a',
1282 'nldr;': '\u2025',
1283 'nlE;': '\u2266\u0338',
1284 'nle;': '\u2270',
1285 'nLeftarrow;': '\u21cd',
1286 'nleftarrow;': '\u219a',
1287 'nLeftrightarrow;': '\u21ce',
1288 'nleftrightarrow;': '\u21ae',
1289 'nleq;': '\u2270',
1290 'nleqq;': '\u2266\u0338',
1291 'nleqslant;': '\u2a7d\u0338',
1292 'nles;': '\u2a7d\u0338',
1293 'nless;': '\u226e',
1294 'nLl;': '\u22d8\u0338',
1295 'nlsim;': '\u2274',
1296 'nLt;': '\u226a\u20d2',
1297 'nlt;': '\u226e',
1298 'nltri;': '\u22ea',
1299 'nltrie;': '\u22ec',
1300 'nLtv;': '\u226a\u0338',
1301 'nmid;': '\u2224',
1302 'NoBreak;': '\u2060',
1303 'NonBreakingSpace;': '\xa0',
1304 'Nopf;': '\u2115',
1305 'nopf;': '\U0001d55f',
1306 'not': '\xac',
1307 'Not;': '\u2aec',
1308 'not;': '\xac',
1309 'NotCongruent;': '\u2262',
1310 'NotCupCap;': '\u226d',
1311 'NotDoubleVerticalBar;': '\u2226',
1312 'NotElement;': '\u2209',
1313 'NotEqual;': '\u2260',
1314 'NotEqualTilde;': '\u2242\u0338',
1315 'NotExists;': '\u2204',
1316 'NotGreater;': '\u226f',
1317 'NotGreaterEqual;': '\u2271',
1318 'NotGreaterFullEqual;': '\u2267\u0338',
1319 'NotGreaterGreater;': '\u226b\u0338',
1320 'NotGreaterLess;': '\u2279',
1321 'NotGreaterSlantEqual;': '\u2a7e\u0338',
1322 'NotGreaterTilde;': '\u2275',
1323 'NotHumpDownHump;': '\u224e\u0338',
1324 'NotHumpEqual;': '\u224f\u0338',
1325 'notin;': '\u2209',
1326 'notindot;': '\u22f5\u0338',
1327 'notinE;': '\u22f9\u0338',
1328 'notinva;': '\u2209',
1329 'notinvb;': '\u22f7',
1330 'notinvc;': '\u22f6',
1331 'NotLeftTriangle;': '\u22ea',
1332 'NotLeftTriangleBar;': '\u29cf\u0338',
1333 'NotLeftTriangleEqual;': '\u22ec',
1334 'NotLess;': '\u226e',
1335 'NotLessEqual;': '\u2270',
1336 'NotLessGreater;': '\u2278',
1337 'NotLessLess;': '\u226a\u0338',
1338 'NotLessSlantEqual;': '\u2a7d\u0338',
1339 'NotLessTilde;': '\u2274',
1340 'NotNestedGreaterGreater;': '\u2aa2\u0338',
1341 'NotNestedLessLess;': '\u2aa1\u0338',
1342 'notni;': '\u220c',
1343 'notniva;': '\u220c',
1344 'notnivb;': '\u22fe',
1345 'notnivc;': '\u22fd',
1346 'NotPrecedes;': '\u2280',
1347 'NotPrecedesEqual;': '\u2aaf\u0338',
1348 'NotPrecedesSlantEqual;': '\u22e0',
1349 'NotReverseElement;': '\u220c',
1350 'NotRightTriangle;': '\u22eb',
1351 'NotRightTriangleBar;': '\u29d0\u0338',
1352 'NotRightTriangleEqual;': '\u22ed',
1353 'NotSquareSubset;': '\u228f\u0338',
1354 'NotSquareSubsetEqual;': '\u22e2',
1355 'NotSquareSuperset;': '\u2290\u0338',
1356 'NotSquareSupersetEqual;': '\u22e3',
1357 'NotSubset;': '\u2282\u20d2',
1358 'NotSubsetEqual;': '\u2288',
1359 'NotSucceeds;': '\u2281',
1360 'NotSucceedsEqual;': '\u2ab0\u0338',
1361 'NotSucceedsSlantEqual;': '\u22e1',
1362 'NotSucceedsTilde;': '\u227f\u0338',
1363 'NotSuperset;': '\u2283\u20d2',
1364 'NotSupersetEqual;': '\u2289',
1365 'NotTilde;': '\u2241',
1366 'NotTildeEqual;': '\u2244',
1367 'NotTildeFullEqual;': '\u2247',
1368 'NotTildeTilde;': '\u2249',
1369 'NotVerticalBar;': '\u2224',
1370 'npar;': '\u2226',
1371 'nparallel;': '\u2226',
1372 'nparsl;': '\u2afd\u20e5',
1373 'npart;': '\u2202\u0338',
1374 'npolint;': '\u2a14',
1375 'npr;': '\u2280',
1376 'nprcue;': '\u22e0',
1377 'npre;': '\u2aaf\u0338',
1378 'nprec;': '\u2280',
1379 'npreceq;': '\u2aaf\u0338',
1380 'nrArr;': '\u21cf',
1381 'nrarr;': '\u219b',
1382 'nrarrc;': '\u2933\u0338',
1383 'nrarrw;': '\u219d\u0338',
1384 'nRightarrow;': '\u21cf',
1385 'nrightarrow;': '\u219b',
1386 'nrtri;': '\u22eb',
1387 'nrtrie;': '\u22ed',
1388 'nsc;': '\u2281',
1389 'nsccue;': '\u22e1',
1390 'nsce;': '\u2ab0\u0338',
1391 'Nscr;': '\U0001d4a9',
1392 'nscr;': '\U0001d4c3',
1393 'nshortmid;': '\u2224',
1394 'nshortparallel;': '\u2226',
1395 'nsim;': '\u2241',
1396 'nsime;': '\u2244',
1397 'nsimeq;': '\u2244',
1398 'nsmid;': '\u2224',
1399 'nspar;': '\u2226',
1400 'nsqsube;': '\u22e2',
1401 'nsqsupe;': '\u22e3',
1402 'nsub;': '\u2284',
1403 'nsubE;': '\u2ac5\u0338',
1404 'nsube;': '\u2288',
1405 'nsubset;': '\u2282\u20d2',
1406 'nsubseteq;': '\u2288',
1407 'nsubseteqq;': '\u2ac5\u0338',
1408 'nsucc;': '\u2281',
1409 'nsucceq;': '\u2ab0\u0338',
1410 'nsup;': '\u2285',
1411 'nsupE;': '\u2ac6\u0338',
1412 'nsupe;': '\u2289',
1413 'nsupset;': '\u2283\u20d2',
1414 'nsupseteq;': '\u2289',
1415 'nsupseteqq;': '\u2ac6\u0338',
1416 'ntgl;': '\u2279',
1417 'Ntilde': '\xd1',
1418 'ntilde': '\xf1',
1419 'Ntilde;': '\xd1',
1420 'ntilde;': '\xf1',
1421 'ntlg;': '\u2278',
1422 'ntriangleleft;': '\u22ea',
1423 'ntrianglelefteq;': '\u22ec',
1424 'ntriangleright;': '\u22eb',
1425 'ntrianglerighteq;': '\u22ed',
1426 'Nu;': '\u039d',
1427 'nu;': '\u03bd',
1428 'num;': '#',
1429 'numero;': '\u2116',
1430 'numsp;': '\u2007',
1431 'nvap;': '\u224d\u20d2',
1432 'nVDash;': '\u22af',
1433 'nVdash;': '\u22ae',
1434 'nvDash;': '\u22ad',
1435 'nvdash;': '\u22ac',
1436 'nvge;': '\u2265\u20d2',
1437 'nvgt;': '>\u20d2',
1438 'nvHarr;': '\u2904',
1439 'nvinfin;': '\u29de',
1440 'nvlArr;': '\u2902',
1441 'nvle;': '\u2264\u20d2',
1442 'nvlt;': '<\u20d2',
1443 'nvltrie;': '\u22b4\u20d2',
1444 'nvrArr;': '\u2903',
1445 'nvrtrie;': '\u22b5\u20d2',
1446 'nvsim;': '\u223c\u20d2',
1447 'nwarhk;': '\u2923',
1448 'nwArr;': '\u21d6',
1449 'nwarr;': '\u2196',
1450 'nwarrow;': '\u2196',
1451 'nwnear;': '\u2927',
1452 'Oacute': '\xd3',
1453 'oacute': '\xf3',
1454 'Oacute;': '\xd3',
1455 'oacute;': '\xf3',
1456 'oast;': '\u229b',
1457 'ocir;': '\u229a',
1458 'Ocirc': '\xd4',
1459 'ocirc': '\xf4',
1460 'Ocirc;': '\xd4',
1461 'ocirc;': '\xf4',
1462 'Ocy;': '\u041e',
1463 'ocy;': '\u043e',
1464 'odash;': '\u229d',
1465 'Odblac;': '\u0150',
1466 'odblac;': '\u0151',
1467 'odiv;': '\u2a38',
1468 'odot;': '\u2299',
1469 'odsold;': '\u29bc',
1470 'OElig;': '\u0152',
1471 'oelig;': '\u0153',
1472 'ofcir;': '\u29bf',
1473 'Ofr;': '\U0001d512',
1474 'ofr;': '\U0001d52c',
1475 'ogon;': '\u02db',
1476 'Ograve': '\xd2',
1477 'ograve': '\xf2',
1478 'Ograve;': '\xd2',
1479 'ograve;': '\xf2',
1480 'ogt;': '\u29c1',
1481 'ohbar;': '\u29b5',
1482 'ohm;': '\u03a9',
1483 'oint;': '\u222e',
1484 'olarr;': '\u21ba',
1485 'olcir;': '\u29be',
1486 'olcross;': '\u29bb',
1487 'oline;': '\u203e',
1488 'olt;': '\u29c0',
1489 'Omacr;': '\u014c',
1490 'omacr;': '\u014d',
1491 'Omega;': '\u03a9',
1492 'omega;': '\u03c9',
1493 'Omicron;': '\u039f',
1494 'omicron;': '\u03bf',
1495 'omid;': '\u29b6',
1496 'ominus;': '\u2296',
1497 'Oopf;': '\U0001d546',
1498 'oopf;': '\U0001d560',
1499 'opar;': '\u29b7',
1500 'OpenCurlyDoubleQuote;': '\u201c',
1501 'OpenCurlyQuote;': '\u2018',
1502 'operp;': '\u29b9',
1503 'oplus;': '\u2295',
1504 'Or;': '\u2a54',
1505 'or;': '\u2228',
1506 'orarr;': '\u21bb',
1507 'ord;': '\u2a5d',
1508 'order;': '\u2134',
1509 'orderof;': '\u2134',
1510 'ordf': '\xaa',
1511 'ordf;': '\xaa',
1512 'ordm': '\xba',
1513 'ordm;': '\xba',
1514 'origof;': '\u22b6',
1515 'oror;': '\u2a56',
1516 'orslope;': '\u2a57',
1517 'orv;': '\u2a5b',
1518 'oS;': '\u24c8',
1519 'Oscr;': '\U0001d4aa',
1520 'oscr;': '\u2134',
1521 'Oslash': '\xd8',
1522 'oslash': '\xf8',
1523 'Oslash;': '\xd8',
1524 'oslash;': '\xf8',
1525 'osol;': '\u2298',
1526 'Otilde': '\xd5',
1527 'otilde': '\xf5',
1528 'Otilde;': '\xd5',
1529 'otilde;': '\xf5',
1530 'Otimes;': '\u2a37',
1531 'otimes;': '\u2297',
1532 'otimesas;': '\u2a36',
1533 'Ouml': '\xd6',
1534 'ouml': '\xf6',
1535 'Ouml;': '\xd6',
1536 'ouml;': '\xf6',
1537 'ovbar;': '\u233d',
1538 'OverBar;': '\u203e',
1539 'OverBrace;': '\u23de',
1540 'OverBracket;': '\u23b4',
1541 'OverParenthesis;': '\u23dc',
1542 'par;': '\u2225',
1543 'para': '\xb6',
1544 'para;': '\xb6',
1545 'parallel;': '\u2225',
1546 'parsim;': '\u2af3',
1547 'parsl;': '\u2afd',
1548 'part;': '\u2202',
1549 'PartialD;': '\u2202',
1550 'Pcy;': '\u041f',
1551 'pcy;': '\u043f',
1552 'percnt;': '%',
1553 'period;': '.',
1554 'permil;': '\u2030',
1555 'perp;': '\u22a5',
1556 'pertenk;': '\u2031',
1557 'Pfr;': '\U0001d513',
1558 'pfr;': '\U0001d52d',
1559 'Phi;': '\u03a6',
1560 'phi;': '\u03c6',
1561 'phiv;': '\u03d5',
1562 'phmmat;': '\u2133',
1563 'phone;': '\u260e',
1564 'Pi;': '\u03a0',
1565 'pi;': '\u03c0',
1566 'pitchfork;': '\u22d4',
1567 'piv;': '\u03d6',
1568 'planck;': '\u210f',
1569 'planckh;': '\u210e',
1570 'plankv;': '\u210f',
1571 'plus;': '+',
1572 'plusacir;': '\u2a23',
1573 'plusb;': '\u229e',
1574 'pluscir;': '\u2a22',
1575 'plusdo;': '\u2214',
1576 'plusdu;': '\u2a25',
1577 'pluse;': '\u2a72',
1578 'PlusMinus;': '\xb1',
1579 'plusmn': '\xb1',
1580 'plusmn;': '\xb1',
1581 'plussim;': '\u2a26',
1582 'plustwo;': '\u2a27',
1583 'pm;': '\xb1',
1584 'Poincareplane;': '\u210c',
1585 'pointint;': '\u2a15',
1586 'Popf;': '\u2119',
1587 'popf;': '\U0001d561',
1588 'pound': '\xa3',
1589 'pound;': '\xa3',
1590 'Pr;': '\u2abb',
1591 'pr;': '\u227a',
1592 'prap;': '\u2ab7',
1593 'prcue;': '\u227c',
1594 'prE;': '\u2ab3',
1595 'pre;': '\u2aaf',
1596 'prec;': '\u227a',
1597 'precapprox;': '\u2ab7',
1598 'preccurlyeq;': '\u227c',
1599 'Precedes;': '\u227a',
1600 'PrecedesEqual;': '\u2aaf',
1601 'PrecedesSlantEqual;': '\u227c',
1602 'PrecedesTilde;': '\u227e',
1603 'preceq;': '\u2aaf',
1604 'precnapprox;': '\u2ab9',
1605 'precneqq;': '\u2ab5',
1606 'precnsim;': '\u22e8',
1607 'precsim;': '\u227e',
1608 'Prime;': '\u2033',
1609 'prime;': '\u2032',
1610 'primes;': '\u2119',
1611 'prnap;': '\u2ab9',
1612 'prnE;': '\u2ab5',
1613 'prnsim;': '\u22e8',
1614 'prod;': '\u220f',
1615 'Product;': '\u220f',
1616 'profalar;': '\u232e',
1617 'profline;': '\u2312',
1618 'profsurf;': '\u2313',
1619 'prop;': '\u221d',
1620 'Proportion;': '\u2237',
1621 'Proportional;': '\u221d',
1622 'propto;': '\u221d',
1623 'prsim;': '\u227e',
1624 'prurel;': '\u22b0',
1625 'Pscr;': '\U0001d4ab',
1626 'pscr;': '\U0001d4c5',
1627 'Psi;': '\u03a8',
1628 'psi;': '\u03c8',
1629 'puncsp;': '\u2008',
1630 'Qfr;': '\U0001d514',
1631 'qfr;': '\U0001d52e',
1632 'qint;': '\u2a0c',
1633 'Qopf;': '\u211a',
1634 'qopf;': '\U0001d562',
1635 'qprime;': '\u2057',
1636 'Qscr;': '\U0001d4ac',
1637 'qscr;': '\U0001d4c6',
1638 'quaternions;': '\u210d',
1639 'quatint;': '\u2a16',
1640 'quest;': '?',
1641 'questeq;': '\u225f',
1642 'QUOT': '"',
1643 'quot': '"',
1644 'QUOT;': '"',
1645 'quot;': '"',
1646 'rAarr;': '\u21db',
1647 'race;': '\u223d\u0331',
1648 'Racute;': '\u0154',
1649 'racute;': '\u0155',
1650 'radic;': '\u221a',
1651 'raemptyv;': '\u29b3',
1652 'Rang;': '\u27eb',
1653 'rang;': '\u27e9',
1654 'rangd;': '\u2992',
1655 'range;': '\u29a5',
1656 'rangle;': '\u27e9',
1657 'raquo': '\xbb',
1658 'raquo;': '\xbb',
1659 'Rarr;': '\u21a0',
1660 'rArr;': '\u21d2',
1661 'rarr;': '\u2192',
1662 'rarrap;': '\u2975',
1663 'rarrb;': '\u21e5',
1664 'rarrbfs;': '\u2920',
1665 'rarrc;': '\u2933',
1666 'rarrfs;': '\u291e',
1667 'rarrhk;': '\u21aa',
1668 'rarrlp;': '\u21ac',
1669 'rarrpl;': '\u2945',
1670 'rarrsim;': '\u2974',
1671 'Rarrtl;': '\u2916',
1672 'rarrtl;': '\u21a3',
1673 'rarrw;': '\u219d',
1674 'rAtail;': '\u291c',
1675 'ratail;': '\u291a',
1676 'ratio;': '\u2236',
1677 'rationals;': '\u211a',
1678 'RBarr;': '\u2910',
1679 'rBarr;': '\u290f',
1680 'rbarr;': '\u290d',
1681 'rbbrk;': '\u2773',
1682 'rbrace;': '}',
1683 'rbrack;': ']',
1684 'rbrke;': '\u298c',
1685 'rbrksld;': '\u298e',
1686 'rbrkslu;': '\u2990',
1687 'Rcaron;': '\u0158',
1688 'rcaron;': '\u0159',
1689 'Rcedil;': '\u0156',
1690 'rcedil;': '\u0157',
1691 'rceil;': '\u2309',
1692 'rcub;': '}',
1693 'Rcy;': '\u0420',
1694 'rcy;': '\u0440',
1695 'rdca;': '\u2937',
1696 'rdldhar;': '\u2969',
1697 'rdquo;': '\u201d',
1698 'rdquor;': '\u201d',
1699 'rdsh;': '\u21b3',
1700 'Re;': '\u211c',
1701 'real;': '\u211c',
1702 'realine;': '\u211b',
1703 'realpart;': '\u211c',
1704 'reals;': '\u211d',
1705 'rect;': '\u25ad',
1706 'REG': '\xae',
1707 'reg': '\xae',
1708 'REG;': '\xae',
1709 'reg;': '\xae',
1710 'ReverseElement;': '\u220b',
1711 'ReverseEquilibrium;': '\u21cb',
1712 'ReverseUpEquilibrium;': '\u296f',
1713 'rfisht;': '\u297d',
1714 'rfloor;': '\u230b',
1715 'Rfr;': '\u211c',
1716 'rfr;': '\U0001d52f',
1717 'rHar;': '\u2964',
1718 'rhard;': '\u21c1',
1719 'rharu;': '\u21c0',
1720 'rharul;': '\u296c',
1721 'Rho;': '\u03a1',
1722 'rho;': '\u03c1',
1723 'rhov;': '\u03f1',
1724 'RightAngleBracket;': '\u27e9',
1725 'RightArrow;': '\u2192',
1726 'Rightarrow;': '\u21d2',
1727 'rightarrow;': '\u2192',
1728 'RightArrowBar;': '\u21e5',
1729 'RightArrowLeftArrow;': '\u21c4',
1730 'rightarrowtail;': '\u21a3',
1731 'RightCeiling;': '\u2309',
1732 'RightDoubleBracket;': '\u27e7',
1733 'RightDownTeeVector;': '\u295d',
1734 'RightDownVector;': '\u21c2',
1735 'RightDownVectorBar;': '\u2955',
1736 'RightFloor;': '\u230b',
1737 'rightharpoondown;': '\u21c1',
1738 'rightharpoonup;': '\u21c0',
1739 'rightleftarrows;': '\u21c4',
1740 'rightleftharpoons;': '\u21cc',
1741 'rightrightarrows;': '\u21c9',
1742 'rightsquigarrow;': '\u219d',
1743 'RightTee;': '\u22a2',
1744 'RightTeeArrow;': '\u21a6',
1745 'RightTeeVector;': '\u295b',
1746 'rightthreetimes;': '\u22cc',
1747 'RightTriangle;': '\u22b3',
1748 'RightTriangleBar;': '\u29d0',
1749 'RightTriangleEqual;': '\u22b5',
1750 'RightUpDownVector;': '\u294f',
1751 'RightUpTeeVector;': '\u295c',
1752 'RightUpVector;': '\u21be',
1753 'RightUpVectorBar;': '\u2954',
1754 'RightVector;': '\u21c0',
1755 'RightVectorBar;': '\u2953',
1756 'ring;': '\u02da',
1757 'risingdotseq;': '\u2253',
1758 'rlarr;': '\u21c4',
1759 'rlhar;': '\u21cc',
1760 'rlm;': '\u200f',
1761 'rmoust;': '\u23b1',
1762 'rmoustache;': '\u23b1',
1763 'rnmid;': '\u2aee',
1764 'roang;': '\u27ed',
1765 'roarr;': '\u21fe',
1766 'robrk;': '\u27e7',
1767 'ropar;': '\u2986',
1768 'Ropf;': '\u211d',
1769 'ropf;': '\U0001d563',
1770 'roplus;': '\u2a2e',
1771 'rotimes;': '\u2a35',
1772 'RoundImplies;': '\u2970',
1773 'rpar;': ')',
1774 'rpargt;': '\u2994',
1775 'rppolint;': '\u2a12',
1776 'rrarr;': '\u21c9',
1777 'Rrightarrow;': '\u21db',
1778 'rsaquo;': '\u203a',
1779 'Rscr;': '\u211b',
1780 'rscr;': '\U0001d4c7',
1781 'Rsh;': '\u21b1',
1782 'rsh;': '\u21b1',
1783 'rsqb;': ']',
1784 'rsquo;': '\u2019',
1785 'rsquor;': '\u2019',
1786 'rthree;': '\u22cc',
1787 'rtimes;': '\u22ca',
1788 'rtri;': '\u25b9',
1789 'rtrie;': '\u22b5',
1790 'rtrif;': '\u25b8',
1791 'rtriltri;': '\u29ce',
1792 'RuleDelayed;': '\u29f4',
1793 'ruluhar;': '\u2968',
1794 'rx;': '\u211e',
1795 'Sacute;': '\u015a',
1796 'sacute;': '\u015b',
1797 'sbquo;': '\u201a',
1798 'Sc;': '\u2abc',
1799 'sc;': '\u227b',
1800 'scap;': '\u2ab8',
1801 'Scaron;': '\u0160',
1802 'scaron;': '\u0161',
1803 'sccue;': '\u227d',
1804 'scE;': '\u2ab4',
1805 'sce;': '\u2ab0',
1806 'Scedil;': '\u015e',
1807 'scedil;': '\u015f',
1808 'Scirc;': '\u015c',
1809 'scirc;': '\u015d',
1810 'scnap;': '\u2aba',
1811 'scnE;': '\u2ab6',
1812 'scnsim;': '\u22e9',
1813 'scpolint;': '\u2a13',
1814 'scsim;': '\u227f',
1815 'Scy;': '\u0421',
1816 'scy;': '\u0441',
1817 'sdot;': '\u22c5',
1818 'sdotb;': '\u22a1',
1819 'sdote;': '\u2a66',
1820 'searhk;': '\u2925',
1821 'seArr;': '\u21d8',
1822 'searr;': '\u2198',
1823 'searrow;': '\u2198',
1824 'sect': '\xa7',
1825 'sect;': '\xa7',
1826 'semi;': ';',
1827 'seswar;': '\u2929',
1828 'setminus;': '\u2216',
1829 'setmn;': '\u2216',
1830 'sext;': '\u2736',
1831 'Sfr;': '\U0001d516',
1832 'sfr;': '\U0001d530',
1833 'sfrown;': '\u2322',
1834 'sharp;': '\u266f',
1835 'SHCHcy;': '\u0429',
1836 'shchcy;': '\u0449',
1837 'SHcy;': '\u0428',
1838 'shcy;': '\u0448',
1839 'ShortDownArrow;': '\u2193',
1840 'ShortLeftArrow;': '\u2190',
1841 'shortmid;': '\u2223',
1842 'shortparallel;': '\u2225',
1843 'ShortRightArrow;': '\u2192',
1844 'ShortUpArrow;': '\u2191',
1845 'shy': '\xad',
1846 'shy;': '\xad',
1847 'Sigma;': '\u03a3',
1848 'sigma;': '\u03c3',
1849 'sigmaf;': '\u03c2',
1850 'sigmav;': '\u03c2',
1851 'sim;': '\u223c',
1852 'simdot;': '\u2a6a',
1853 'sime;': '\u2243',
1854 'simeq;': '\u2243',
1855 'simg;': '\u2a9e',
1856 'simgE;': '\u2aa0',
1857 'siml;': '\u2a9d',
1858 'simlE;': '\u2a9f',
1859 'simne;': '\u2246',
1860 'simplus;': '\u2a24',
1861 'simrarr;': '\u2972',
1862 'slarr;': '\u2190',
1863 'SmallCircle;': '\u2218',
1864 'smallsetminus;': '\u2216',
1865 'smashp;': '\u2a33',
1866 'smeparsl;': '\u29e4',
1867 'smid;': '\u2223',
1868 'smile;': '\u2323',
1869 'smt;': '\u2aaa',
1870 'smte;': '\u2aac',
1871 'smtes;': '\u2aac\ufe00',
1872 'SOFTcy;': '\u042c',
1873 'softcy;': '\u044c',
1874 'sol;': '/',
1875 'solb;': '\u29c4',
1876 'solbar;': '\u233f',
1877 'Sopf;': '\U0001d54a',
1878 'sopf;': '\U0001d564',
1879 'spades;': '\u2660',
1880 'spadesuit;': '\u2660',
1881 'spar;': '\u2225',
1882 'sqcap;': '\u2293',
1883 'sqcaps;': '\u2293\ufe00',
1884 'sqcup;': '\u2294',
1885 'sqcups;': '\u2294\ufe00',
1886 'Sqrt;': '\u221a',
1887 'sqsub;': '\u228f',
1888 'sqsube;': '\u2291',
1889 'sqsubset;': '\u228f',
1890 'sqsubseteq;': '\u2291',
1891 'sqsup;': '\u2290',
1892 'sqsupe;': '\u2292',
1893 'sqsupset;': '\u2290',
1894 'sqsupseteq;': '\u2292',
1895 'squ;': '\u25a1',
1896 'Square;': '\u25a1',
1897 'square;': '\u25a1',
1898 'SquareIntersection;': '\u2293',
1899 'SquareSubset;': '\u228f',
1900 'SquareSubsetEqual;': '\u2291',
1901 'SquareSuperset;': '\u2290',
1902 'SquareSupersetEqual;': '\u2292',
1903 'SquareUnion;': '\u2294',
1904 'squarf;': '\u25aa',
1905 'squf;': '\u25aa',
1906 'srarr;': '\u2192',
1907 'Sscr;': '\U0001d4ae',
1908 'sscr;': '\U0001d4c8',
1909 'ssetmn;': '\u2216',
1910 'ssmile;': '\u2323',
1911 'sstarf;': '\u22c6',
1912 'Star;': '\u22c6',
1913 'star;': '\u2606',
1914 'starf;': '\u2605',
1915 'straightepsilon;': '\u03f5',
1916 'straightphi;': '\u03d5',
1917 'strns;': '\xaf',
1918 'Sub;': '\u22d0',
1919 'sub;': '\u2282',
1920 'subdot;': '\u2abd',
1921 'subE;': '\u2ac5',
1922 'sube;': '\u2286',
1923 'subedot;': '\u2ac3',
1924 'submult;': '\u2ac1',
1925 'subnE;': '\u2acb',
1926 'subne;': '\u228a',
1927 'subplus;': '\u2abf',
1928 'subrarr;': '\u2979',
1929 'Subset;': '\u22d0',
1930 'subset;': '\u2282',
1931 'subseteq;': '\u2286',
1932 'subseteqq;': '\u2ac5',
1933 'SubsetEqual;': '\u2286',
1934 'subsetneq;': '\u228a',
1935 'subsetneqq;': '\u2acb',
1936 'subsim;': '\u2ac7',
1937 'subsub;': '\u2ad5',
1938 'subsup;': '\u2ad3',
1939 'succ;': '\u227b',
1940 'succapprox;': '\u2ab8',
1941 'succcurlyeq;': '\u227d',
1942 'Succeeds;': '\u227b',
1943 'SucceedsEqual;': '\u2ab0',
1944 'SucceedsSlantEqual;': '\u227d',
1945 'SucceedsTilde;': '\u227f',
1946 'succeq;': '\u2ab0',
1947 'succnapprox;': '\u2aba',
1948 'succneqq;': '\u2ab6',
1949 'succnsim;': '\u22e9',
1950 'succsim;': '\u227f',
1951 'SuchThat;': '\u220b',
1952 'Sum;': '\u2211',
1953 'sum;': '\u2211',
1954 'sung;': '\u266a',
1955 'sup1': '\xb9',
1956 'sup1;': '\xb9',
1957 'sup2': '\xb2',
1958 'sup2;': '\xb2',
1959 'sup3': '\xb3',
1960 'sup3;': '\xb3',
1961 'Sup;': '\u22d1',
1962 'sup;': '\u2283',
1963 'supdot;': '\u2abe',
1964 'supdsub;': '\u2ad8',
1965 'supE;': '\u2ac6',
1966 'supe;': '\u2287',
1967 'supedot;': '\u2ac4',
1968 'Superset;': '\u2283',
1969 'SupersetEqual;': '\u2287',
1970 'suphsol;': '\u27c9',
1971 'suphsub;': '\u2ad7',
1972 'suplarr;': '\u297b',
1973 'supmult;': '\u2ac2',
1974 'supnE;': '\u2acc',
1975 'supne;': '\u228b',
1976 'supplus;': '\u2ac0',
1977 'Supset;': '\u22d1',
1978 'supset;': '\u2283',
1979 'supseteq;': '\u2287',
1980 'supseteqq;': '\u2ac6',
1981 'supsetneq;': '\u228b',
1982 'supsetneqq;': '\u2acc',
1983 'supsim;': '\u2ac8',
1984 'supsub;': '\u2ad4',
1985 'supsup;': '\u2ad6',
1986 'swarhk;': '\u2926',
1987 'swArr;': '\u21d9',
1988 'swarr;': '\u2199',
1989 'swarrow;': '\u2199',
1990 'swnwar;': '\u292a',
1991 'szlig': '\xdf',
1992 'szlig;': '\xdf',
1993 'Tab;': '\t',
1994 'target;': '\u2316',
1995 'Tau;': '\u03a4',
1996 'tau;': '\u03c4',
1997 'tbrk;': '\u23b4',
1998 'Tcaron;': '\u0164',
1999 'tcaron;': '\u0165',
2000 'Tcedil;': '\u0162',
2001 'tcedil;': '\u0163',
2002 'Tcy;': '\u0422',
2003 'tcy;': '\u0442',
2004 'tdot;': '\u20db',
2005 'telrec;': '\u2315',
2006 'Tfr;': '\U0001d517',
2007 'tfr;': '\U0001d531',
2008 'there4;': '\u2234',
2009 'Therefore;': '\u2234',
2010 'therefore;': '\u2234',
2011 'Theta;': '\u0398',
2012 'theta;': '\u03b8',
2013 'thetasym;': '\u03d1',
2014 'thetav;': '\u03d1',
2015 'thickapprox;': '\u2248',
2016 'thicksim;': '\u223c',
2017 'ThickSpace;': '\u205f\u200a',
2018 'thinsp;': '\u2009',
2019 'ThinSpace;': '\u2009',
2020 'thkap;': '\u2248',
2021 'thksim;': '\u223c',
2022 'THORN': '\xde',
2023 'thorn': '\xfe',
2024 'THORN;': '\xde',
2025 'thorn;': '\xfe',
2026 'Tilde;': '\u223c',
2027 'tilde;': '\u02dc',
2028 'TildeEqual;': '\u2243',
2029 'TildeFullEqual;': '\u2245',
2030 'TildeTilde;': '\u2248',
2031 'times': '\xd7',
2032 'times;': '\xd7',
2033 'timesb;': '\u22a0',
2034 'timesbar;': '\u2a31',
2035 'timesd;': '\u2a30',
2036 'tint;': '\u222d',
2037 'toea;': '\u2928',
2038 'top;': '\u22a4',
2039 'topbot;': '\u2336',
2040 'topcir;': '\u2af1',
2041 'Topf;': '\U0001d54b',
2042 'topf;': '\U0001d565',
2043 'topfork;': '\u2ada',
2044 'tosa;': '\u2929',
2045 'tprime;': '\u2034',
2046 'TRADE;': '\u2122',
2047 'trade;': '\u2122',
2048 'triangle;': '\u25b5',
2049 'triangledown;': '\u25bf',
2050 'triangleleft;': '\u25c3',
2051 'trianglelefteq;': '\u22b4',
2052 'triangleq;': '\u225c',
2053 'triangleright;': '\u25b9',
2054 'trianglerighteq;': '\u22b5',
2055 'tridot;': '\u25ec',
2056 'trie;': '\u225c',
2057 'triminus;': '\u2a3a',
2058 'TripleDot;': '\u20db',
2059 'triplus;': '\u2a39',
2060 'trisb;': '\u29cd',
2061 'tritime;': '\u2a3b',
2062 'trpezium;': '\u23e2',
2063 'Tscr;': '\U0001d4af',
2064 'tscr;': '\U0001d4c9',
2065 'TScy;': '\u0426',
2066 'tscy;': '\u0446',
2067 'TSHcy;': '\u040b',
2068 'tshcy;': '\u045b',
2069 'Tstrok;': '\u0166',
2070 'tstrok;': '\u0167',
2071 'twixt;': '\u226c',
2072 'twoheadleftarrow;': '\u219e',
2073 'twoheadrightarrow;': '\u21a0',
2074 'Uacute': '\xda',
2075 'uacute': '\xfa',
2076 'Uacute;': '\xda',
2077 'uacute;': '\xfa',
2078 'Uarr;': '\u219f',
2079 'uArr;': '\u21d1',
2080 'uarr;': '\u2191',
2081 'Uarrocir;': '\u2949',
2082 'Ubrcy;': '\u040e',
2083 'ubrcy;': '\u045e',
2084 'Ubreve;': '\u016c',
2085 'ubreve;': '\u016d',
2086 'Ucirc': '\xdb',
2087 'ucirc': '\xfb',
2088 'Ucirc;': '\xdb',
2089 'ucirc;': '\xfb',
2090 'Ucy;': '\u0423',
2091 'ucy;': '\u0443',
2092 'udarr;': '\u21c5',
2093 'Udblac;': '\u0170',
2094 'udblac;': '\u0171',
2095 'udhar;': '\u296e',
2096 'ufisht;': '\u297e',
2097 'Ufr;': '\U0001d518',
2098 'ufr;': '\U0001d532',
2099 'Ugrave': '\xd9',
2100 'ugrave': '\xf9',
2101 'Ugrave;': '\xd9',
2102 'ugrave;': '\xf9',
2103 'uHar;': '\u2963',
2104 'uharl;': '\u21bf',
2105 'uharr;': '\u21be',
2106 'uhblk;': '\u2580',
2107 'ulcorn;': '\u231c',
2108 'ulcorner;': '\u231c',
2109 'ulcrop;': '\u230f',
2110 'ultri;': '\u25f8',
2111 'Umacr;': '\u016a',
2112 'umacr;': '\u016b',
2113 'uml': '\xa8',
2114 'uml;': '\xa8',
2115 'UnderBar;': '_',
2116 'UnderBrace;': '\u23df',
2117 'UnderBracket;': '\u23b5',
2118 'UnderParenthesis;': '\u23dd',
2119 'Union;': '\u22c3',
2120 'UnionPlus;': '\u228e',
2121 'Uogon;': '\u0172',
2122 'uogon;': '\u0173',
2123 'Uopf;': '\U0001d54c',
2124 'uopf;': '\U0001d566',
2125 'UpArrow;': '\u2191',
2126 'Uparrow;': '\u21d1',
2127 'uparrow;': '\u2191',
2128 'UpArrowBar;': '\u2912',
2129 'UpArrowDownArrow;': '\u21c5',
2130 'UpDownArrow;': '\u2195',
2131 'Updownarrow;': '\u21d5',
2132 'updownarrow;': '\u2195',
2133 'UpEquilibrium;': '\u296e',
2134 'upharpoonleft;': '\u21bf',
2135 'upharpoonright;': '\u21be',
2136 'uplus;': '\u228e',
2137 'UpperLeftArrow;': '\u2196',
2138 'UpperRightArrow;': '\u2197',
2139 'Upsi;': '\u03d2',
2140 'upsi;': '\u03c5',
2141 'upsih;': '\u03d2',
2142 'Upsilon;': '\u03a5',
2143 'upsilon;': '\u03c5',
2144 'UpTee;': '\u22a5',
2145 'UpTeeArrow;': '\u21a5',
2146 'upuparrows;': '\u21c8',
2147 'urcorn;': '\u231d',
2148 'urcorner;': '\u231d',
2149 'urcrop;': '\u230e',
2150 'Uring;': '\u016e',
2151 'uring;': '\u016f',
2152 'urtri;': '\u25f9',
2153 'Uscr;': '\U0001d4b0',
2154 'uscr;': '\U0001d4ca',
2155 'utdot;': '\u22f0',
2156 'Utilde;': '\u0168',
2157 'utilde;': '\u0169',
2158 'utri;': '\u25b5',
2159 'utrif;': '\u25b4',
2160 'uuarr;': '\u21c8',
2161 'Uuml': '\xdc',
2162 'uuml': '\xfc',
2163 'Uuml;': '\xdc',
2164 'uuml;': '\xfc',
2165 'uwangle;': '\u29a7',
2166 'vangrt;': '\u299c',
2167 'varepsilon;': '\u03f5',
2168 'varkappa;': '\u03f0',
2169 'varnothing;': '\u2205',
2170 'varphi;': '\u03d5',
2171 'varpi;': '\u03d6',
2172 'varpropto;': '\u221d',
2173 'vArr;': '\u21d5',
2174 'varr;': '\u2195',
2175 'varrho;': '\u03f1',
2176 'varsigma;': '\u03c2',
2177 'varsubsetneq;': '\u228a\ufe00',
2178 'varsubsetneqq;': '\u2acb\ufe00',
2179 'varsupsetneq;': '\u228b\ufe00',
2180 'varsupsetneqq;': '\u2acc\ufe00',
2181 'vartheta;': '\u03d1',
2182 'vartriangleleft;': '\u22b2',
2183 'vartriangleright;': '\u22b3',
2184 'Vbar;': '\u2aeb',
2185 'vBar;': '\u2ae8',
2186 'vBarv;': '\u2ae9',
2187 'Vcy;': '\u0412',
2188 'vcy;': '\u0432',
2189 'VDash;': '\u22ab',
2190 'Vdash;': '\u22a9',
2191 'vDash;': '\u22a8',
2192 'vdash;': '\u22a2',
2193 'Vdashl;': '\u2ae6',
2194 'Vee;': '\u22c1',
2195 'vee;': '\u2228',
2196 'veebar;': '\u22bb',
2197 'veeeq;': '\u225a',
2198 'vellip;': '\u22ee',
2199 'Verbar;': '\u2016',
2200 'verbar;': '|',
2201 'Vert;': '\u2016',
2202 'vert;': '|',
2203 'VerticalBar;': '\u2223',
2204 'VerticalLine;': '|',
2205 'VerticalSeparator;': '\u2758',
2206 'VerticalTilde;': '\u2240',
2207 'VeryThinSpace;': '\u200a',
2208 'Vfr;': '\U0001d519',
2209 'vfr;': '\U0001d533',
2210 'vltri;': '\u22b2',
2211 'vnsub;': '\u2282\u20d2',
2212 'vnsup;': '\u2283\u20d2',
2213 'Vopf;': '\U0001d54d',
2214 'vopf;': '\U0001d567',
2215 'vprop;': '\u221d',
2216 'vrtri;': '\u22b3',
2217 'Vscr;': '\U0001d4b1',
2218 'vscr;': '\U0001d4cb',
2219 'vsubnE;': '\u2acb\ufe00',
2220 'vsubne;': '\u228a\ufe00',
2221 'vsupnE;': '\u2acc\ufe00',
2222 'vsupne;': '\u228b\ufe00',
2223 'Vvdash;': '\u22aa',
2224 'vzigzag;': '\u299a',
2225 'Wcirc;': '\u0174',
2226 'wcirc;': '\u0175',
2227 'wedbar;': '\u2a5f',
2228 'Wedge;': '\u22c0',
2229 'wedge;': '\u2227',
2230 'wedgeq;': '\u2259',
2231 'weierp;': '\u2118',
2232 'Wfr;': '\U0001d51a',
2233 'wfr;': '\U0001d534',
2234 'Wopf;': '\U0001d54e',
2235 'wopf;': '\U0001d568',
2236 'wp;': '\u2118',
2237 'wr;': '\u2240',
2238 'wreath;': '\u2240',
2239 'Wscr;': '\U0001d4b2',
2240 'wscr;': '\U0001d4cc',
2241 'xcap;': '\u22c2',
2242 'xcirc;': '\u25ef',
2243 'xcup;': '\u22c3',
2244 'xdtri;': '\u25bd',
2245 'Xfr;': '\U0001d51b',
2246 'xfr;': '\U0001d535',
2247 'xhArr;': '\u27fa',
2248 'xharr;': '\u27f7',
2249 'Xi;': '\u039e',
2250 'xi;': '\u03be',
2251 'xlArr;': '\u27f8',
2252 'xlarr;': '\u27f5',
2253 'xmap;': '\u27fc',
2254 'xnis;': '\u22fb',
2255 'xodot;': '\u2a00',
2256 'Xopf;': '\U0001d54f',
2257 'xopf;': '\U0001d569',
2258 'xoplus;': '\u2a01',
2259 'xotime;': '\u2a02',
2260 'xrArr;': '\u27f9',
2261 'xrarr;': '\u27f6',
2262 'Xscr;': '\U0001d4b3',
2263 'xscr;': '\U0001d4cd',
2264 'xsqcup;': '\u2a06',
2265 'xuplus;': '\u2a04',
2266 'xutri;': '\u25b3',
2267 'xvee;': '\u22c1',
2268 'xwedge;': '\u22c0',
2269 'Yacute': '\xdd',
2270 'yacute': '\xfd',
2271 'Yacute;': '\xdd',
2272 'yacute;': '\xfd',
2273 'YAcy;': '\u042f',
2274 'yacy;': '\u044f',
2275 'Ycirc;': '\u0176',
2276 'ycirc;': '\u0177',
2277 'Ycy;': '\u042b',
2278 'ycy;': '\u044b',
2279 'yen': '\xa5',
2280 'yen;': '\xa5',
2281 'Yfr;': '\U0001d51c',
2282 'yfr;': '\U0001d536',
2283 'YIcy;': '\u0407',
2284 'yicy;': '\u0457',
2285 'Yopf;': '\U0001d550',
2286 'yopf;': '\U0001d56a',
2287 'Yscr;': '\U0001d4b4',
2288 'yscr;': '\U0001d4ce',
2289 'YUcy;': '\u042e',
2290 'yucy;': '\u044e',
2291 'yuml': '\xff',
2292 'Yuml;': '\u0178',
2293 'yuml;': '\xff',
2294 'Zacute;': '\u0179',
2295 'zacute;': '\u017a',
2296 'Zcaron;': '\u017d',
2297 'zcaron;': '\u017e',
2298 'Zcy;': '\u0417',
2299 'zcy;': '\u0437',
2300 'Zdot;': '\u017b',
2301 'zdot;': '\u017c',
2302 'zeetrf;': '\u2128',
2303 'ZeroWidthSpace;': '\u200b',
2304 'Zeta;': '\u0396',
2305 'zeta;': '\u03b6',
2306 'Zfr;': '\u2128',
2307 'zfr;': '\U0001d537',
2308 'ZHcy;': '\u0416',
2309 'zhcy;': '\u0436',
2310 'zigrarr;': '\u21dd',
2311 'Zopf;': '\u2124',
2312 'zopf;': '\U0001d56b',
2313 'Zscr;': '\U0001d4b5',
2314 'zscr;': '\U0001d4cf',
2315 'zwj;': '\u200d',
2316 'zwnj;': '\u200c',
2317 }
2318
2319 try:
2320 import http.client as compat_http_client
2321 except ImportError: # Python 2
2322 import httplib as compat_http_client
2323
2324 try:
2325 from urllib.error import HTTPError as compat_HTTPError
2326 except ImportError: # Python 2
2327 from urllib2 import HTTPError as compat_HTTPError
2328
2329 try:
2330 from urllib.request import urlretrieve as compat_urlretrieve
2331 except ImportError: # Python 2
2332 from urllib import urlretrieve as compat_urlretrieve
2333
2334 try:
2335 from html.parser import HTMLParser as compat_HTMLParser
2336 except ImportError: # Python 2
2337 from HTMLParser import HTMLParser as compat_HTMLParser
2338
2339 try: # Python 2
2340 from HTMLParser import HTMLParseError as compat_HTMLParseError
2341 except ImportError: # Python <3.4
2342 try:
2343 from html.parser import HTMLParseError as compat_HTMLParseError
2344 except ImportError: # Python >3.4
2345
2346 # HTMLParseError has been deprecated in Python 3.3 and removed in
2347 # Python 3.5. Introducing dummy exception for Python >3.5 for compatible
2348 # and uniform cross-version exceptiong handling
2349 class compat_HTMLParseError(Exception):
2350 pass
2351
2352 try:
2353 from subprocess import DEVNULL
2354 compat_subprocess_get_DEVNULL = lambda: DEVNULL
2355 except ImportError:
2356 compat_subprocess_get_DEVNULL = lambda: open(os.path.devnull, 'w')
2357
2358 try:
2359 import http.server as compat_http_server
2360 except ImportError:
2361 import BaseHTTPServer as compat_http_server
2362
2363 try:
2364 compat_str = unicode # Python 2
2365 except NameError:
2366 compat_str = str
2367
2368 try:
2369 from urllib.parse import unquote_to_bytes as compat_urllib_parse_unquote_to_bytes
2370 from urllib.parse import unquote as compat_urllib_parse_unquote
2371 from urllib.parse import unquote_plus as compat_urllib_parse_unquote_plus
2372 except ImportError: # Python 2
2373 _asciire = (compat_urllib_parse._asciire if hasattr(compat_urllib_parse, '_asciire')
2374 else re.compile(r'([\x00-\x7f]+)'))
2375
2376 # HACK: The following are the correct unquote_to_bytes, unquote and unquote_plus
2377 # implementations from cpython 3.4.3's stdlib. Python 2's version
2378 # is apparently broken (see https://github.com/ytdl-org/youtube-dl/pull/6244)
2379
2380 def compat_urllib_parse_unquote_to_bytes(string):
2381 """unquote_to_bytes('abc%20def') -> b'abc def'."""
2382 # Note: strings are encoded as UTF-8. This is only an issue if it contains
2383 # unescaped non-ASCII characters, which URIs should not.
2384 if not string:
2385 # Is it a string-like object?
2386 string.split
2387 return b''
2388 if isinstance(string, compat_str):
2389 string = string.encode('utf-8')
2390 bits = string.split(b'%')
2391 if len(bits) == 1:
2392 return string
2393 res = [bits[0]]
2394 append = res.append
2395 for item in bits[1:]:
2396 try:
2397 append(compat_urllib_parse._hextochr[item[:2]])
2398 append(item[2:])
2399 except KeyError:
2400 append(b'%')
2401 append(item)
2402 return b''.join(res)
2403
2404 def compat_urllib_parse_unquote(string, encoding='utf-8', errors='replace'):
2405 """Replace %xx escapes by their single-character equivalent. The optional
2406 encoding and errors parameters specify how to decode percent-encoded
2407 sequences into Unicode characters, as accepted by the bytes.decode()
2408 method.
2409 By default, percent-encoded sequences are decoded with UTF-8, and invalid
2410 sequences are replaced by a placeholder character.
2411
2412 unquote('abc%20def') -> 'abc def'.
2413 """
2414 if '%' not in string:
2415 string.split
2416 return string
2417 if encoding is None:
2418 encoding = 'utf-8'
2419 if errors is None:
2420 errors = 'replace'
2421 bits = _asciire.split(string)
2422 res = [bits[0]]
2423 append = res.append
2424 for i in range(1, len(bits), 2):
2425 append(compat_urllib_parse_unquote_to_bytes(bits[i]).decode(encoding, errors))
2426 append(bits[i + 1])
2427 return ''.join(res)
2428
2429 def compat_urllib_parse_unquote_plus(string, encoding='utf-8', errors='replace'):
2430 """Like unquote(), but also replace plus signs by spaces, as required for
2431 unquoting HTML form values.
2432
2433 unquote_plus('%7e/abc+def') -> '~/abc def'
2434 """
2435 string = string.replace('+', ' ')
2436 return compat_urllib_parse_unquote(string, encoding, errors)
2437
2438 try:
2439 from urllib.parse import urlencode as compat_urllib_parse_urlencode
2440 except ImportError: # Python 2
2441 # Python 2 will choke in urlencode on mixture of byte and unicode strings.
2442 # Possible solutions are to either port it from python 3 with all
2443 # the friends or manually ensure input query contains only byte strings.
2444 # We will stick with latter thus recursively encoding the whole query.
2445 def compat_urllib_parse_urlencode(query, doseq=0, encoding='utf-8'):
2446 def encode_elem(e):
2447 if isinstance(e, dict):
2448 e = encode_dict(e)
2449 elif isinstance(e, (list, tuple,)):
2450 list_e = encode_list(e)
2451 e = tuple(list_e) if isinstance(e, tuple) else list_e
2452 elif isinstance(e, compat_str):
2453 e = e.encode(encoding)
2454 return e
2455
2456 def encode_dict(d):
2457 return dict((encode_elem(k), encode_elem(v)) for k, v in d.items())
2458
2459 def encode_list(l):
2460 return [encode_elem(e) for e in l]
2461
2462 return compat_urllib_parse.urlencode(encode_elem(query), doseq=doseq)
2463
2464 try:
2465 from urllib.request import DataHandler as compat_urllib_request_DataHandler
2466 except ImportError: # Python < 3.4
2467 # Ported from CPython 98774:1733b3bd46db, Lib/urllib/request.py
2468 class compat_urllib_request_DataHandler(compat_urllib_request.BaseHandler):
2469 def data_open(self, req):
2470 # data URLs as specified in RFC 2397.
2471 #
2472 # ignores POSTed data
2473 #
2474 # syntax:
2475 # dataurl := "data:" [ mediatype ] [ ";base64" ] "," data
2476 # mediatype := [ type "/" subtype ] *( ";" parameter )
2477 # data := *urlchar
2478 # parameter := attribute "=" value
2479 url = req.get_full_url()
2480
2481 scheme, data = url.split(':', 1)
2482 mediatype, data = data.split(',', 1)
2483
2484 # even base64 encoded data URLs might be quoted so unquote in any case:
2485 data = compat_urllib_parse_unquote_to_bytes(data)
2486 if mediatype.endswith(';base64'):
2487 data = binascii.a2b_base64(data)
2488 mediatype = mediatype[:-7]
2489
2490 if not mediatype:
2491 mediatype = 'text/plain;charset=US-ASCII'
2492
2493 headers = email.message_from_string(
2494 'Content-type: %s\nContent-length: %d\n' % (mediatype, len(data)))
2495
2496 return compat_urllib_response.addinfourl(io.BytesIO(data), headers, url)
2497
2498 try:
2499 compat_basestring = basestring # Python 2
2500 except NameError:
2501 compat_basestring = str
2502
2503 try:
2504 compat_chr = unichr # Python 2
2505 except NameError:
2506 compat_chr = chr
2507
2508 try:
2509 from xml.etree.ElementTree import ParseError as compat_xml_parse_error
2510 except ImportError: # Python 2.6
2511 from xml.parsers.expat import ExpatError as compat_xml_parse_error
2512
2513
2514 etree = xml.etree.ElementTree
2515
2516
2517 class _TreeBuilder(etree.TreeBuilder):
2518 def doctype(self, name, pubid, system):
2519 pass
2520
2521
2522 try:
2523 # xml.etree.ElementTree.Element is a method in Python <=2.6 and
2524 # the following will crash with:
2525 # TypeError: isinstance() arg 2 must be a class, type, or tuple of classes and types
2526 isinstance(None, xml.etree.ElementTree.Element)
2527 from xml.etree.ElementTree import Element as compat_etree_Element
2528 except TypeError: # Python <=2.6
2529 from xml.etree.ElementTree import _ElementInterface as compat_etree_Element
2530
2531 if sys.version_info[0] >= 3:
2532 def compat_etree_fromstring(text):
2533 return etree.XML(text, parser=etree.XMLParser(target=_TreeBuilder()))
2534 else:
2535 # python 2.x tries to encode unicode strings with ascii (see the
2536 # XMLParser._fixtext method)
2537 try:
2538 _etree_iter = etree.Element.iter
2539 except AttributeError: # Python <=2.6
2540 def _etree_iter(root):
2541 for el in root.findall('*'):
2542 yield el
2543 for sub in _etree_iter(el):
2544 yield sub
2545
2546 # on 2.6 XML doesn't have a parser argument, function copied from CPython
2547 # 2.7 source
2548 def _XML(text, parser=None):
2549 if not parser:
2550 parser = etree.XMLParser(target=_TreeBuilder())
2551 parser.feed(text)
2552 return parser.close()
2553
2554 def _element_factory(*args, **kwargs):
2555 el = etree.Element(*args, **kwargs)
2556 for k, v in el.items():
2557 if isinstance(v, bytes):
2558 el.set(k, v.decode('utf-8'))
2559 return el
2560
2561 def compat_etree_fromstring(text):
2562 doc = _XML(text, parser=etree.XMLParser(target=_TreeBuilder(element_factory=_element_factory)))
2563 for el in _etree_iter(doc):
2564 if el.text is not None and isinstance(el.text, bytes):
2565 el.text = el.text.decode('utf-8')
2566 return doc
2567
2568 if hasattr(etree, 'register_namespace'):
2569 compat_etree_register_namespace = etree.register_namespace
2570 else:
2571 def compat_etree_register_namespace(prefix, uri):
2572 """Register a namespace prefix.
2573 The registry is global, and any existing mapping for either the
2574 given prefix or the namespace URI will be removed.
2575 *prefix* is the namespace prefix, *uri* is a namespace uri. Tags and
2576 attributes in this namespace will be serialized with prefix if possible.
2577 ValueError is raised if prefix is reserved or is invalid.
2578 """
2579 if re.match(r"ns\d+$", prefix):
2580 raise ValueError("Prefix format reserved for internal use")
2581 for k, v in list(etree._namespace_map.items()):
2582 if k == uri or v == prefix:
2583 del etree._namespace_map[k]
2584 etree._namespace_map[uri] = prefix
2585
2586 if sys.version_info < (2, 7):
2587 # Here comes the crazy part: In 2.6, if the xpath is a unicode,
2588 # .//node does not match if a node is a direct child of . !
2589 def compat_xpath(xpath):
2590 if isinstance(xpath, compat_str):
2591 xpath = xpath.encode('ascii')
2592 return xpath
2593 else:
2594 compat_xpath = lambda xpath: xpath
2595
2596 try:
2597 from urllib.parse import parse_qs as compat_parse_qs
2598 except ImportError: # Python 2
2599 # HACK: The following is the correct parse_qs implementation from cpython 3's stdlib.
2600 # Python 2's version is apparently totally broken
2601
2602 def _parse_qsl(qs, keep_blank_values=False, strict_parsing=False,
2603 encoding='utf-8', errors='replace'):
2604 qs, _coerce_result = qs, compat_str
2605 pairs = [s2 for s1 in qs.split('&') for s2 in s1.split(';')]
2606 r = []
2607 for name_value in pairs:
2608 if not name_value and not strict_parsing:
2609 continue
2610 nv = name_value.split('=', 1)
2611 if len(nv) != 2:
2612 if strict_parsing:
2613 raise ValueError('bad query field: %r' % (name_value,))
2614 # Handle case of a control-name with no equal sign
2615 if keep_blank_values:
2616 nv.append('')
2617 else:
2618 continue
2619 if len(nv[1]) or keep_blank_values:
2620 name = nv[0].replace('+', ' ')
2621 name = compat_urllib_parse_unquote(
2622 name, encoding=encoding, errors=errors)
2623 name = _coerce_result(name)
2624 value = nv[1].replace('+', ' ')
2625 value = compat_urllib_parse_unquote(
2626 value, encoding=encoding, errors=errors)
2627 value = _coerce_result(value)
2628 r.append((name, value))
2629 return r
2630
2631 def compat_parse_qs(qs, keep_blank_values=False, strict_parsing=False,
2632 encoding='utf-8', errors='replace'):
2633 parsed_result = {}
2634 pairs = _parse_qsl(qs, keep_blank_values, strict_parsing,
2635 encoding=encoding, errors=errors)
2636 for name, value in pairs:
2637 if name in parsed_result:
2638 parsed_result[name].append(value)
2639 else:
2640 parsed_result[name] = [value]
2641 return parsed_result
2642
2643
2644 compat_os_name = os._name if os.name == 'java' else os.name
2645
2646
2647 if compat_os_name == 'nt':
2648 def compat_shlex_quote(s):
2649 return s if re.match(r'^[-_\w./]+$', s) else '"%s"' % s.replace('"', '\\"')
2650 else:
2651 try:
2652 from shlex import quote as compat_shlex_quote
2653 except ImportError: # Python < 3.3
2654 def compat_shlex_quote(s):
2655 if re.match(r'^[-_\w./]+$', s):
2656 return s
2657 else:
2658 return "'" + s.replace("'", "'\"'\"'") + "'"
2659
2660
2661 try:
2662 args = shlex.split('äø­ę–‡')
2663 assert (isinstance(args, list)
2664 and isinstance(args[0], compat_str)
2665 and args[0] == 'äø­ę–‡')
2666 compat_shlex_split = shlex.split
2667 except (AssertionError, UnicodeEncodeError):
2668 # Working around shlex issue with unicode strings on some python 2
2669 # versions (see http://bugs.python.org/issue1548891)
2670 def compat_shlex_split(s, comments=False, posix=True):
2671 if isinstance(s, compat_str):
2672 s = s.encode('utf-8')
2673 return list(map(lambda s: s.decode('utf-8'), shlex.split(s, comments, posix)))
2674
2675
2676 def compat_ord(c):
2677 if type(c) is int:
2678 return c
2679 else:
2680 return ord(c)
2681
2682
2683 if sys.version_info >= (3, 0):
2684 compat_getenv = os.getenv
2685 compat_expanduser = os.path.expanduser
2686
2687 def compat_setenv(key, value, env=os.environ):
2688 env[key] = value
2689 else:
2690 # Environment variables should be decoded with filesystem encoding.
2691 # Otherwise it will fail if any non-ASCII characters present (see #3854 #3217 #2918)
2692
2693 def compat_getenv(key, default=None):
2694 from .utils import get_filesystem_encoding
2695 env = os.getenv(key, default)
2696 if env:
2697 env = env.decode(get_filesystem_encoding())
2698 return env
2699
2700 def compat_setenv(key, value, env=os.environ):
2701 def encode(v):
2702 from .utils import get_filesystem_encoding
2703 return v.encode(get_filesystem_encoding()) if isinstance(v, compat_str) else v
2704 env[encode(key)] = encode(value)
2705
2706 # HACK: The default implementations of os.path.expanduser from cpython do not decode
2707 # environment variables with filesystem encoding. We will work around this by
2708 # providing adjusted implementations.
2709 # The following are os.path.expanduser implementations from cpython 2.7.8 stdlib
2710 # for different platforms with correct environment variables decoding.
2711
2712 if compat_os_name == 'posix':
2713 def compat_expanduser(path):
2714 """Expand ~ and ~user constructions. If user or $HOME is unknown,
2715 do nothing."""
2716 if not path.startswith('~'):
2717 return path
2718 i = path.find('/', 1)
2719 if i < 0:
2720 i = len(path)
2721 if i == 1:
2722 if 'HOME' not in os.environ:
2723 import pwd
2724 userhome = pwd.getpwuid(os.getuid()).pw_dir
2725 else:
2726 userhome = compat_getenv('HOME')
2727 else:
2728 import pwd
2729 try:
2730 pwent = pwd.getpwnam(path[1:i])
2731 except KeyError:
2732 return path
2733 userhome = pwent.pw_dir
2734 userhome = userhome.rstrip('/')
2735 return (userhome + path[i:]) or '/'
2736 elif compat_os_name in ('nt', 'ce'):
2737 def compat_expanduser(path):
2738 """Expand ~ and ~user constructs.
2739
2740 If user or $HOME is unknown, do nothing."""
2741 if path[:1] != '~':
2742 return path
2743 i, n = 1, len(path)
2744 while i < n and path[i] not in '/\\':
2745 i = i + 1
2746
2747 if 'HOME' in os.environ:
2748 userhome = compat_getenv('HOME')
2749 elif 'USERPROFILE' in os.environ:
2750 userhome = compat_getenv('USERPROFILE')
2751 elif 'HOMEPATH' not in os.environ:
2752 return path
2753 else:
2754 try:
2755 drive = compat_getenv('HOMEDRIVE')
2756 except KeyError:
2757 drive = ''
2758 userhome = os.path.join(drive, compat_getenv('HOMEPATH'))
2759
2760 if i != 1: # ~user
2761 userhome = os.path.join(os.path.dirname(userhome), path[1:i])
2762
2763 return userhome + path[i:]
2764 else:
2765 compat_expanduser = os.path.expanduser
2766
2767
2768 if compat_os_name == 'nt' and sys.version_info < (3, 8):
2769 # os.path.realpath on Windows does not follow symbolic links
2770 # prior to Python 3.8 (see https://bugs.python.org/issue9949)
2771 def compat_realpath(path):
2772 while os.path.islink(path):
2773 path = os.path.abspath(os.readlink(path))
2774 return path
2775 else:
2776 compat_realpath = os.path.realpath
2777
2778
2779 if sys.version_info < (3, 0):
2780 def compat_print(s):
2781 from .utils import preferredencoding
2782 print(s.encode(preferredencoding(), 'xmlcharrefreplace'))
2783 else:
2784 def compat_print(s):
2785 assert isinstance(s, compat_str)
2786 print(s)
2787
2788
2789 if sys.version_info < (3, 0) and sys.platform == 'win32':
2790 def compat_getpass(prompt, *args, **kwargs):
2791 if isinstance(prompt, compat_str):
2792 from .utils import preferredencoding
2793 prompt = prompt.encode(preferredencoding())
2794 return getpass.getpass(prompt, *args, **kwargs)
2795 else:
2796 compat_getpass = getpass.getpass
2797
2798 try:
2799 compat_input = raw_input
2800 except NameError: # Python 3
2801 compat_input = input
2802
2803 # Python < 2.6.5 require kwargs to be bytes
2804 try:
2805 def _testfunc(x):
2806 pass
2807 _testfunc(**{'x': 0})
2808 except TypeError:
2809 def compat_kwargs(kwargs):
2810 return dict((bytes(k), v) for k, v in kwargs.items())
2811 else:
2812 compat_kwargs = lambda kwargs: kwargs
2813
2814
2815 try:
2816 compat_numeric_types = (int, float, long, complex)
2817 except NameError: # Python 3
2818 compat_numeric_types = (int, float, complex)
2819
2820
2821 try:
2822 compat_integer_types = (int, long)
2823 except NameError: # Python 3
2824 compat_integer_types = (int, )
2825
2826
2827 if sys.version_info < (2, 7):
2828 def compat_socket_create_connection(address, timeout, source_address=None):
2829 host, port = address
2830 err = None
2831 for res in socket.getaddrinfo(host, port, 0, socket.SOCK_STREAM):
2832 af, socktype, proto, canonname, sa = res
2833 sock = None
2834 try:
2835 sock = socket.socket(af, socktype, proto)
2836 sock.settimeout(timeout)
2837 if source_address:
2838 sock.bind(source_address)
2839 sock.connect(sa)
2840 return sock
2841 except socket.error as _:
2842 err = _
2843 if sock is not None:
2844 sock.close()
2845 if err is not None:
2846 raise err
2847 else:
2848 raise socket.error('getaddrinfo returns an empty list')
2849 else:
2850 compat_socket_create_connection = socket.create_connection
2851
2852
2853 # Fix https://github.com/ytdl-org/youtube-dl/issues/4223
2854 # See http://bugs.python.org/issue9161 for what is broken
2855 def workaround_optparse_bug9161():
2856 op = optparse.OptionParser()
2857 og = optparse.OptionGroup(op, 'foo')
2858 try:
2859 og.add_option('-t')
2860 except TypeError:
2861 real_add_option = optparse.OptionGroup.add_option
2862
2863 def _compat_add_option(self, *args, **kwargs):
2864 enc = lambda v: (
2865 v.encode('ascii', 'replace') if isinstance(v, compat_str)
2866 else v)
2867 bargs = [enc(a) for a in args]
2868 bkwargs = dict(
2869 (k, enc(v)) for k, v in kwargs.items())
2870 return real_add_option(self, *bargs, **bkwargs)
2871 optparse.OptionGroup.add_option = _compat_add_option
2872
2873
2874 if hasattr(shutil, 'get_terminal_size'): # Python >= 3.3
2875 compat_get_terminal_size = shutil.get_terminal_size
2876 else:
2877 _terminal_size = collections.namedtuple('terminal_size', ['columns', 'lines'])
2878
2879 def compat_get_terminal_size(fallback=(80, 24)):
2880 columns = compat_getenv('COLUMNS')
2881 if columns:
2882 columns = int(columns)
2883 else:
2884 columns = None
2885 lines = compat_getenv('LINES')
2886 if lines:
2887 lines = int(lines)
2888 else:
2889 lines = None
2890
2891 if columns is None or lines is None or columns <= 0 or lines <= 0:
2892 try:
2893 sp = subprocess.Popen(
2894 ['stty', 'size'],
2895 stdout=subprocess.PIPE, stderr=subprocess.PIPE)
2896 out, err = sp.communicate()
2897 _lines, _columns = map(int, out.split())
2898 except Exception:
2899 _columns, _lines = _terminal_size(*fallback)
2900
2901 if columns is None or columns <= 0:
2902 columns = _columns
2903 if lines is None or lines <= 0:
2904 lines = _lines
2905 return _terminal_size(columns, lines)
2906
2907 try:
2908 itertools.count(start=0, step=1)
2909 compat_itertools_count = itertools.count
2910 except TypeError: # Python 2.6
2911 def compat_itertools_count(start=0, step=1):
2912 n = start
2913 while True:
2914 yield n
2915 n += step
2916
2917 if sys.version_info >= (3, 0):
2918 from tokenize import tokenize as compat_tokenize_tokenize
2919 else:
2920 from tokenize import generate_tokens as compat_tokenize_tokenize
2921
2922
2923 try:
2924 struct.pack('!I', 0)
2925 except TypeError:
2926 # In Python 2.6 and 2.7.x < 2.7.7, struct requires a bytes argument
2927 # See https://bugs.python.org/issue19099
2928 def compat_struct_pack(spec, *args):
2929 if isinstance(spec, compat_str):
2930 spec = spec.encode('ascii')
2931 return struct.pack(spec, *args)
2932
2933 def compat_struct_unpack(spec, *args):
2934 if isinstance(spec, compat_str):
2935 spec = spec.encode('ascii')
2936 return struct.unpack(spec, *args)
2937
2938 class compat_Struct(struct.Struct):
2939 def __init__(self, fmt):
2940 if isinstance(fmt, compat_str):
2941 fmt = fmt.encode('ascii')
2942 super(compat_Struct, self).__init__(fmt)
2943 else:
2944 compat_struct_pack = struct.pack
2945 compat_struct_unpack = struct.unpack
2946 if platform.python_implementation() == 'IronPython' and sys.version_info < (2, 7, 8):
2947 class compat_Struct(struct.Struct):
2948 def unpack(self, string):
2949 if not isinstance(string, buffer): # noqa: F821
2950 string = buffer(string) # noqa: F821
2951 return super(compat_Struct, self).unpack(string)
2952 else:
2953 compat_Struct = struct.Struct
2954
2955
2956 try:
2957 from future_builtins import zip as compat_zip
2958 except ImportError: # not 2.6+ or is 3.x
2959 try:
2960 from itertools import izip as compat_zip # < 2.5 or 3.x
2961 except ImportError:
2962 compat_zip = zip
2963
2964
2965 if sys.version_info < (3, 3):
2966 def compat_b64decode(s, *args, **kwargs):
2967 if isinstance(s, compat_str):
2968 s = s.encode('ascii')
2969 return base64.b64decode(s, *args, **kwargs)
2970 else:
2971 compat_b64decode = base64.b64decode
2972
2973
2974 if platform.python_implementation() == 'PyPy' and sys.pypy_version_info < (5, 4, 0):
2975 # PyPy2 prior to version 5.4.0 expects byte strings as Windows function
2976 # names, see the original PyPy issue [1] and the youtube-dl one [2].
2977 # 1. https://bitbucket.org/pypy/pypy/issues/2360/windows-ctypescdll-typeerror-function-name
2978 # 2. https://github.com/ytdl-org/youtube-dl/pull/4392
2979 def compat_ctypes_WINFUNCTYPE(*args, **kwargs):
2980 real = ctypes.WINFUNCTYPE(*args, **kwargs)
2981
2982 def resf(tpl, *args, **kwargs):
2983 funcname, dll = tpl
2984 return real((str(funcname), dll), *args, **kwargs)
2985
2986 return resf
2987 else:
2988 def compat_ctypes_WINFUNCTYPE(*args, **kwargs):
2989 return ctypes.WINFUNCTYPE(*args, **kwargs)
2990
2991
2992 __all__ = [
2993 'compat_HTMLParseError',
2994 'compat_HTMLParser',
2995 'compat_HTTPError',
2996 'compat_Struct',
2997 'compat_b64decode',
2998 'compat_basestring',
2999 'compat_chr',
3000 'compat_cookiejar',
3001 'compat_cookiejar_Cookie',
3002 'compat_cookies',
3003 'compat_ctypes_WINFUNCTYPE',
3004 'compat_etree_Element',
3005 'compat_etree_fromstring',
3006 'compat_etree_register_namespace',
3007 'compat_expanduser',
3008 'compat_get_terminal_size',
3009 'compat_getenv',
3010 'compat_getpass',
3011 'compat_html_entities',
3012 'compat_html_entities_html5',
3013 'compat_http_client',
3014 'compat_http_server',
3015 'compat_input',
3016 'compat_integer_types',
3017 'compat_itertools_count',
3018 'compat_kwargs',
3019 'compat_numeric_types',
3020 'compat_ord',
3021 'compat_os_name',
3022 'compat_parse_qs',
3023 'compat_print',
3024 'compat_realpath',
3025 'compat_setenv',
3026 'compat_shlex_quote',
3027 'compat_shlex_split',
3028 'compat_socket_create_connection',
3029 'compat_str',
3030 'compat_struct_pack',
3031 'compat_struct_unpack',
3032 'compat_subprocess_get_DEVNULL',
3033 'compat_tokenize_tokenize',
3034 'compat_urllib_error',
3035 'compat_urllib_parse',
3036 'compat_urllib_parse_unquote',
3037 'compat_urllib_parse_unquote_plus',
3038 'compat_urllib_parse_unquote_to_bytes',
3039 'compat_urllib_parse_urlencode',
3040 'compat_urllib_parse_urlparse',
3041 'compat_urllib_request',
3042 'compat_urllib_request_DataHandler',
3043 'compat_urllib_response',
3044 'compat_urlparse',
3045 'compat_urlretrieve',
3046 'compat_xml_parse_error',
3047 'compat_xpath',
3048 'compat_zip',
3049 'workaround_optparse_bug9161',
3050 ]