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