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