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