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