zmc
2023-12-22 9fdbf60165db0400c2e8e6be2dc6e88138ac719a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
U
¡ý°dÆ ã@s^dZdZddlmZddlmZddlZddlZddlZddl    Z    dZ
z ddl Z
Wn\e k
r¬z ddl Z
Wn:e k
r¦z ddlZ
Wne k
r dZ
YnXYnXYnXe
r¼dd„Zndd„Zd    Zd
ZeƒZe e d ¡ej¡e e d ¡ej¡d œee<e eej¡e eej¡d œee<dd lmZGdd„deƒZGdd„dƒZGdd„dƒZdS)aBBeautiful Soup bonus library: Unicode, Dammit
 
This library converts a bytestream to Unicode through any means
necessary. It is heavily based on code from Mark Pilgrim's Universal
Feed Parser. It works best on XML and HTML, but it does not rewrite the
XML or HTML to reflect a new encoding; that's the tree builder's job.
ÚMITé)Úcodepoint2name)Ú defaultdictNcCst|tƒrdSt |¡dS)NÚencoding)Ú
isinstanceÚstrÚchardet_moduleÚdetect©Ús©r úAd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\bs4/dammit.pyÚchardet_dammit+s
rcCsdS©Nr r
r r r r0sz$^\s*<\?.*encoding=['"](.*?)['"].*\?>z0<\s*meta[^>]+charset\s*=\s*["']?([^>]*?)[ /;'">]Úascii)ÚhtmlÚxml)Úhtml5c@s”eZdZdZdd„Zeƒ\ZZZdddddd    œZe     
d
¡Z e     
d ¡Z e d d „ƒZe dd„ƒZe dd„ƒZe ddd„ƒZe ddd„ƒZe dd„ƒZdS)ÚEntitySubstitutionzFThe ability to substitute XML or HTML entities for certain characters.cCsŠi}i}tƒ}ttƒ}tt ¡ƒD]¨\}}| d¡rB|dd…}n|}||krV|||<|||<t|ƒdkr€t|ƒdkr€|dkr€q"t|ƒdkr tdd„|Dƒƒr q"t|ƒdkr¸|     |¡q"||d         |¡q"tƒ}|D]B}||}    |    sò|     |¡qÖd
 
d d „|    Dƒ¡}
|     d ||
f¡qÖt |  ¡ƒD]} | D]} |     | ¡q.q&dd 
|¡} t t  ¡ƒD]\}}t|ƒ}|||<q^||t | ¡fS)u¤Initialize variables used by this class to manage the plethora of
        HTML5 named entities.
 
        This function returns a 3-tuple containing two dictionaries
        and a regular expression:
 
        unicode_to_name - A mapping of Unicode strings like "⦨" to
        entity names like "angmsdaa". When a single Unicode string has
        multiple entity names, we try to choose the most commonly-used
        name.
 
        name_to_unicode: A mapping of entity names like "angmsdaa" to 
        Unicode strings like "⦨".
 
        named_entity_re: A regular expression matching (almost) any
        Unicode string that corresponds to an HTML5 named entity.
        ú;Néÿÿÿÿéé€z<>&css|]}t|ƒdkVqdS)rN)Úord©Ú.0Úxr r r Ú    <genexpr>†sz?EntitySubstitution._populate_class_variables.<locals>.<genexpr>rÚcSsg|] }|d‘qS)rr rr r r Ú
<listcomp>¦sz@EntitySubstitution._populate_class_variables.<locals>.<listcomp>z
%s(?![%s])z(%s)ú|)ÚsetrÚsortedrÚitemsÚendswithÚlenrÚallÚaddÚjoinÚlistÚvaluesrÚchrÚreÚcompile)Zunicode_to_nameZname_to_unicodeZshort_entitiesZ long_entities_by_first_characterZname_with_semicolonÚ    characterÚnameZ    particlesÚshortZ long_versionsÚignoreZ long_entitiesZ long_entityZ re_definitionÚ    codepointr r r Ú_populate_class_variablesFsF
 
ÿ    z,EntitySubstitution._populate_class_variablesZaposÚquotÚampÚltÚgt)ú'ú"ú&ú<ú>z&([<>]|&(?!#\d+;|#x[0-9a-fA-F]+;|\w+;))z([<>&])cCs|j | d¡¡}d|S)zpUsed with a regular expression to substitute the
        appropriate HTML entity for a special character string.rú&%s;)ÚCHARACTER_TO_HTML_ENTITYÚgetÚgroup©ÚclsZmatchobjÚentityr r r Ú_substitute_html_entityÍsz*EntitySubstitution._substitute_html_entitycCs|j| d¡}d|S)zoUsed with a regular expression to substitute the
        appropriate XML entity for a special character string.rr=)ÚCHARACTER_TO_XML_ENTITYr@rAr r r Ú_substitute_xml_entityÔsz)EntitySubstitution._substitute_xml_entitycCs6d}d|kr*d|kr&d}| d|¡}nd}|||S)a*Make a value into a quoted XML attribute, possibly escaping it.
 
         Most strings will be quoted using double quotes.
 
          Bob's Bar -> "Bob's Bar"
 
         If a string contains double quotes, it will be quoted using
         single quotes.
 
          Welcome to "my bar" -> 'Welcome to "my bar"'
 
         If a string contains both single and double quotes, the
         double quotes will be escaped, and the string will be quoted
         using double quotes.
 
          Welcome to "Bob's Bar" -> "Welcome to &quot;Bob's bar&quot;
        r9r8z&quot;)Úreplace)ÚselfÚvalueZ
quote_withZ replace_withr r r Úquoted_attribute_valueÛsz)EntitySubstitution.quoted_attribute_valueFcCs"|j |j|¡}|r| |¡}|S)a Substitute XML entities for special XML characters.
 
        :param value: A string to be substituted. The less-than sign
          will become &lt;, the greater-than sign will become &gt;,
          and any ampersands will become &amp;. If you want ampersands
          that appear to be part of an entity definition to be left
          alone, use substitute_xml_containing_entities() instead.
 
        :param make_quoted_attribute: If True, then the string will be
         quoted, as befits an attribute value.
        )ÚAMPERSAND_OR_BRACKETÚsubrFrJ©rBrIZmake_quoted_attributer r r Úsubstitute_xmlsÿ
z!EntitySubstitution.substitute_xmlcCs"|j |j|¡}|r| |¡}|S)aŸSubstitute XML entities for special XML characters.
 
        :param value: A string to be substituted. The less-than sign will
          become &lt;, the greater-than sign will become &gt;, and any
          ampersands that are not part of an entity defition will
          become &amp;.
 
        :param make_quoted_attribute: If True, then the string will be
         quoted, as befits an attribute value.
        )ÚBARE_AMPERSAND_OR_BRACKETrLrFrJrMr r r Ú"substitute_xml_containing_entitiessÿ
z5EntitySubstitution.substitute_xml_containing_entitiescCs|j |j|¡S)aReplace certain Unicode characters with named HTML entities.
 
        This differs from data.encode(encoding, 'xmlcharrefreplace')
        in that the goal is to make the result more readable (to those
        with ASCII displays) rather than to recover from
        errors. There's absolutely nothing wrong with a UTF-8 string
        containg a LATIN SMALL LETTER E WITH ACUTE, but replacing that
        character with "&eacute;" will make it more readable to some
        people.
 
        :param s: A Unicode string.
        )ÚCHARACTER_TO_HTML_ENTITY_RErLrD)rBr r r r Úsubstitute_html+sÿz"EntitySubstitution.substitute_htmlN)F)F)Ú__name__Ú
__module__Ú __qualname__Ú__doc__r3r>ZHTML_ENTITY_TO_CHARACTERrQrEr,r-rOrKÚ classmethodrDrFrJrNrPrRr r r r rCs4wÿû
 
 
 
 
$ ÿ rc@sHeZdZdZddd„Zdd„Zedd    „ƒZed
d „ƒZ    edd d „ƒZ
dS)ÚEncodingDetectoraLSuggests a number of possible encodings for a bytestring.
 
    Order of precedence:
 
    1. Encodings you specifically tell EncodingDetector to try first
    (the known_definite_encodings argument to the constructor).
 
    2. An encoding determined by sniffing the document's byte-order mark.
 
    3. Encodings you specifically tell EncodingDetector to try if
    byte-order mark sniffing fails (the user_encodings argument to the
    constructor).
 
    4. An encoding declared within the bytestring itself, either in an
    XML declaration (if the bytestring is to be interpreted as an XML
    document), or in a <meta> tag (if the bytestring is to be
    interpreted as an HTML document.)
 
    5. An encoding detected through textual analysis by chardet,
    cchardet, or a similar external library.
 
    4. UTF-8.
 
    5. Windows-1252.
 
    NFcCsnt|pgƒ|_|r |j|7_|p&g|_|p0g}tdd„|Dƒƒ|_d|_||_d|_| |¡\|_    |_
dS)aConstructor.
 
        :param markup: Some markup in an unknown encoding.
 
        :param known_definite_encodings: When determining the encoding
            of `markup`, these encodings will be tried first, in
            order. In HTML terms, this corresponds to the "known
            definite encoding" step defined here:
            https://html.spec.whatwg.org/multipage/parsing.html#parsing-with-a-known-character-encoding
 
        :param user_encodings: These encodings will be tried after the
            `known_definite_encodings` have been tried and failed, and
            after an attempt to sniff the encoding by looking at a
            byte order mark has failed. In HTML terms, this
            corresponds to the step "user has explicitly instructed
            the user agent to override the document's character
            encoding", defined here:
            https://html.spec.whatwg.org/multipage/parsing.html#determining-the-character-encoding
 
        :param override_encodings: A deprecated alias for
            known_definite_encodings. Any encodings here will be tried
            immediately after the encodings in
            known_definite_encodings.
 
        :param is_html: If True, this markup is considered to be
            HTML. Otherwise it's assumed to be XML.
 
        :param exclude_encodings: These encodings will not be tried,
            even if they otherwise would be.
 
        cSsg|] }| ¡‘qSr )Úlowerrr r r rsz-EncodingDetector.__init__.<locals>.<listcomp>N) r)Úknown_definite_encodingsÚuser_encodingsr!Úexclude_encodingsÚchardet_encodingÚis_htmlÚdeclared_encodingÚstrip_byte_order_markÚmarkupÚsniffed_encoding)rHrarZr^r\r[Úoverride_encodingsr r r Ú__init__Xs"
zEncodingDetector.__init__cCs8|dk    r4| ¡}||jkrdS||kr4| |¡dSdS)zÕShould we even bother to try this encoding?
 
        :param encoding: Name of an encoding.
        :param tried: Encodings that have already been tried. This will be modified
            as a side effect.
        NFT)rYr\r')rHrÚtriedr r r Ú_usable‡s
 
zEncodingDetector._usableccsÖtƒ}|jD]}| ||¡r |Vq | |j|¡r:|jV|jD]}| ||¡r@|Vq@|jdkrt| |j|j¡|_| |j|¡rŠ|jV|j    dkr t
|jƒ|_    | |j    |¡r¶|j    VdD]}| ||¡rº|VqºdS)zmYield a number of encodings that might work for this markup.
 
        :yield: A sequence of strings.
        N)úutf-8ú windows-1252) r!rZrfrbr[r_Úfind_declared_encodingrar^r]r)rHreÚer r r Ú    encodings—s.
 
 
ÿ
  zEncodingDetector.encodingscCsþd}t|tƒr||fSt|ƒdkrT|dd…dkrT|dd…dkrTd}|dd…}n¢t|ƒdkr’|dd…dkr’|dd…dkr’d}|dd…}nd|dd    …d
kr´d }|d    d…}nB|dd…d krÖd }|dd…}n |dd…dkröd}|dd…}||fS)z¶If a byte-order mark is present, strip it and return the encoding it implies.
 
        :param data: Some markup.
        :return: A 2-tuple (modified data, implied encoding)
        Néésþÿzzutf-16besÿþzutf-16leésrgsþÿzutf-32besÿþzutf-32le)rrr%)rBÚdatarr r r r`Ãs.
ÿÿ z&EncodingDetector.strip_byte_order_markc Csº|rt|ƒ}}nd}tdtt|ƒdƒƒ}t|tƒr@tt}ntt}|d}|d}d}    |j||d}
|
s€|r€|j||d}
|
dk    r”|
 ¡d}    |    r¶t|    tƒr®|         d    d
¡}    |     
¡SdS) a§Given a document, tries to find its declared encoding.
 
        An XML encoding is declared at the beginning of the document.
 
        An HTML encoding is declared in a <meta> tag, hopefully near the
        beginning of the document.
 
        :param markup: Some markup.
        :param is_html: If True, this markup is considered to be HTML. Otherwise
            it's assumed to be XML.
        :param search_entire_document: Since an encoding is supposed to declared near the beginning
            of the document, most of the time it's only necessary to search a few kilobytes of data.
            Set this to True to force this method to search the entire document.
        iigš™™™™™©?rrN)ÚendposrrrG) r%ÚmaxÚintrÚbytesÚ encoding_resrÚsearchÚgroupsÚdecoderY) rBrar^Zsearch_entire_documentZ
xml_endposZ html_endposÚresÚxml_reZhtml_rer_Zdeclared_encoding_matchr r r riás(
 
 
 z'EncodingDetector.find_declared_encoding)NFNNN)FF) rSrTrUrVrdrfÚpropertyrkrWr`rir r r r rX=sþ
/
+
rXc@sêeZdZdZdddœZdddgZgdd    gddfd
d „Zd d „Zdþdd„Zdÿdd„Z    e
dd„ƒZ dd„Z dd„Z dddddddd d!d"d#d$d%d&d'd&d&d(d)d*d+d,d-d.d/d0d1d2d3d&d4d5d6œ Zd7dd8d9d:d;d<d=d>d?d@dAdBd&dCd&d&dDdDdEdEdFdGdHdIdJdKdLdMd&dNdOddPdQdRdSdTdUd@dVdWdXdYdPddZdGd[d\d]d^d_d`dadFd8dbdXdcdddedfd&dgdgdgdgdgdgdhdidjdjdjdjdkdkdkdkdldmdndndndndndFdndododododOdpdqdrdrdrdrdrdrdsdQdtdtdtdtdudududud[dvd[d[d[d[d[dwd[d`d`d`d`dxdpdxdyœ€Zdzd{d|d}d~dd€dd‚dƒd„d…d†d‡dˆd‰dŠd‹dŒddŽddd‘d’d“d”d•d–d—d˜d™dšd›dœddždŸd d¡d¢d£d¤d¥d¦d§d¨d©dªd«d¬d­d®d¯d°d±d²d³d´dµd¶d·d¸d¹dºd»d¼d½d¾d¿dÀdÁdÂdÃdÄdÅdÆdÇdÈdÉdÊdËdÌdÍdÎdÏdÐdÑdÒdÓdÔdÕdÖd×dØdÙdÚdÛdÜdÝdÞdßdàdádâdãdädådædçdèdédêdëdìdídîdïdðdñdòdódôœzZdõdöd÷gZedødøZedùdúZeddüdý„ƒZdS(Ú UnicodeDammitzÏA class for detecting the encoding of a *ML document and
    converting it to a Unicode string. If the source encoding is
    windows-1252, can replace MS smart quotes with their HTML or XML
    equivalents.z    mac-romanz    shift-jis)Ú    macintoshzx-sjisrhz
iso-8859-1z
iso-8859-2NFc
Csö||_g|_d|_||_t t¡|_t||||||ƒ|_    t
|t ƒsJ|dkrd||_ t |ƒ|_ d|_dS|j    j |_ d}|j    jD]"}    |j    j }| |    ¡}|dk    rzqžqz|sâ|j    jD]6}    |    dkrÂ| |    d¡}|dk    rª|j d¡d|_qâqª||_ |sòd|_dS)a2Constructor.
 
        :param markup: A bytestring representing markup in an unknown encoding.
 
        :param known_definite_encodings: When determining the encoding
            of `markup`, these encodings will be tried first, in
            order. In HTML terms, this corresponds to the "known
            definite encoding" step defined here:
            https://html.spec.whatwg.org/multipage/parsing.html#parsing-with-a-known-character-encoding
 
        :param user_encodings: These encodings will be tried after the
            `known_definite_encodings` have been tried and failed, and
            after an attempt to sniff the encoding by looking at a
            byte order mark has failed. In HTML terms, this
            corresponds to the step "user has explicitly instructed
            the user agent to override the document's character
            encoding", defined here:
            https://html.spec.whatwg.org/multipage/parsing.html#determining-the-character-encoding
 
        :param override_encodings: A deprecated alias for
            known_definite_encodings. Any encodings here will be tried
            immediately after the encodings in
            known_definite_encodings.
 
        :param smart_quotes_to: By default, Microsoft smart quotes will, like all other characters, be converted
           to Unicode characters. Setting this to 'ascii' will convert them to ASCII quotes instead.
           Setting it to 'xml' will convert them to XML entity references, and setting it to 'html'
           will convert them to HTML entity references.
        :param is_html: If True, this markup is considered to be HTML. Otherwise
            it's assumed to be XML.
        :param exclude_encodings: These encodings will not be considered, even
            if the sniffing code thinks they might make sense.
 
        FrNrrGzSSome characters could not be decoded, and were replaced with REPLACEMENT CHARACTER.T)Úsmart_quotes_toÚtried_encodingsZcontains_replacement_charactersr^ÚloggingÚ    getLoggerrSÚlogrXÚdetectorrrraZunicode_markupÚoriginal_encodingrkÚ _convert_fromÚwarning)
rHrarZr}r^r\r[rcÚurr r r rdsL& þ
 
 
  ÿzUnicodeDammit.__init__cCs| d¡}|jdkr&|j |¡ ¡}nf|j |¡}t|ƒtkr„|jdkrfd ¡|d ¡d ¡}qŒd ¡|d ¡d ¡}n| ¡}|S)z[Changes a MS smart quote character to an XML or HTML
        entity, or an ASCII character.rrrz&#xrr:r)r@r}ÚMS_CHARS_TO_ASCIIr?ÚencodeÚMS_CHARSÚtypeÚtuple)rHÚmatchÚorigrLr r r Ú _sub_ms_charus
 
 
zUnicodeDammit._sub_ms_charÚstrictc
Cs´| |¡}|r||f|jkr dS|j ||f¡|j}|jdk    rf||jkrfd}t |¡}| |j    |¡}z| 
|||¡}||_||_ Wn(t k
r¬}z
WY¢dSd}~XYnX|jS)z|Attempt to convert the markup to the proposed encoding.
 
        :param proposed: The name of a character encoding.
        Ns([€-Ÿ])) Ú
find_codecr~Úappendrar}ÚENCODINGS_WITH_SMART_QUOTESr,r-rLrŽÚ _to_unicoderƒÚ    Exception)rHZproposedÚerrorsraZsmart_quotes_reZsmart_quotes_compiledr†rjr r r r„†s$
 
ÿ
 
zUnicodeDammit._convert_fromcCs t|||ƒS)z}Given a string and its encoding, decodes the string into Unicode.
 
        :param encoding: The name of an encoding.
        )r)rHrorr•r r r r“¥szUnicodeDammit._to_unicodecCs|js
dS|jjS)zhIf the markup is an HTML document, returns the encoding declared _within_
        the document.
        N)r^r‚r_)rHr r r Údeclared_html_encoding¬sz$UnicodeDammit.declared_html_encodingcCs`| |j ||¡¡pN|r*| | dd¡¡pN|r@| | dd¡¡pN|rL| ¡pN|}|r\| ¡SdS)z™Convert the name of a character set to a codec name.
 
        :param charset: The name of a character set.
        :return: The name of a codec.
        ú-rÚ_N)Ú_codecÚCHARSET_ALIASESr?rGrY)rHÚcharsetrIr r r rµsÿþ
ýüzUnicodeDammit.find_codecc    Cs<|s|Sd}zt |¡|}Wnttfk
r6YnX|Sr)ÚcodecsÚlookupÚ LookupErrorÚ
ValueError)rHr›Úcodecr r r r™Ås
zUnicodeDammit._codec)ÚeuroZ20ACú )ÚsbquoZ201A)ÚfnofZ192)ÚbdquoZ201E)ÚhellipZ2026)ÚdaggerZ2020)ÚDaggerZ2021)ÚcircZ2C6)ÚpermilZ2030)ÚScaronZ160)ÚlsaquoZ2039)ÚOEligZ152ú?)z#x17DZ17D)ÚlsquoZ2018)ÚrsquoZ2019)ÚldquoZ201C)ÚrdquoZ201D)ÚbullZ2022)ÚndashZ2013)ÚmdashZ2014)ÚtildeZ2DC)ÚtradeZ2122)ÚscaronZ161)ÚrsaquoZ203A)ÚoeligZ153)z#x17EZ17E)ÚYumlr) ó€óó‚óƒó„ó…ó†ó‡óˆó‰óŠó‹óŒóóŽóóó‘ó’ó“ó”ó•ó–ó—ó˜ó™óšó›óœóóžóŸZEURú,Úfz,,z...ú+z++ú^ú%ÚSr;ZOEÚZr8r9Ú*r—z--ú~z(TM)r r<ZoeÚzÚYú!ÚcZGBPú$ZYENr z..rz(th)z<<z(R)Úoz+-Ú2Ú3)r8Úacuter†ÚPÚ1z>>z1/4z1/2z3/4ÚAZAEÚCÚEÚIÚDÚNÚOÚUÚbÚBÚaZaerjÚiÚnú/Úy)€r¼r½r¾r¿rÀrÁrÂrÃrÄrÅrÆrÇrÈrÉrÊrËrÌrÍrÎrÏrÐrÑrÒrÓrÔrÕrÖr×rØrÙrÚrÛó ó¡ó¢ó£ó¤ó¥ó¦ó§ó¨ó©óªó«ó¬ó­ó®ó¯ó°ó±ó²ó³ó´óµó¶ó·ó¸ó¹óºó»ó¼ó½ó¾ó¿óÀóÁóÂóÃóÄóÅóÆóÇóÈóÉóÊóËóÌóÍóÎóÏóÐóÑóÒóÓóÔóÕóÖó×óØóÙóÚóÛóÜóÝóÞóßóàóáóâóãóäóåóæóçóèóéóêóëóìóíóîóïóðóñóòóóóôóõóöó÷óøóùóúóûóüóýóþóÿs€s‚sƒs„s…s†s‡sˆs‰sÅ s‹sŒsŽs‘s’s“s”s•s–s—s˜s™sÅ¡s›sœsžsŸs s¡s¢s£s¤sÂ¥s¦s§s¨s©sªs«s¬s­s®s¯s°s±s²s³s´sµs¶s·s¸s¹sºs»s¼s½s¾s¿sÀsÁsÂsÃsÄsÅsÆsÇsÈsÉsÊsËsÌsÍsÎsÏsÐsÑsÒsÓsÔsÕsÖs×sØsÙsÚsÛsÜsÝsÞsßsàrsâsãsäsÃ¥sæsçsèsésêsësìsísîsïsðsñsòsósôsõsös÷søsùsúsûsüsýsþ)zré‚éƒé„é…é†é‡éˆé‰éŠé‹éŒéŽé‘é’é“é”é•é–é—é˜é™éšé›éœéžéŸé é¡é¢é£é¤é¥é¦é§é¨é©éªé«é¬é­é®é¯é°é±é²é³é´éµé¶é·é¸é¹éºé»é¼é½é¾é¿éÀéÁéÂéÃéÄéÅéÆéÇéÈéÉéÊéËéÌéÍéÎéÏéÐéÑéÒéÓéÔéÕéÖé×éØéÙéÚéÛéÜéÝéÞéßéàéáéâéãéäéåéæéçéèéééêéëéìéíéîéïéðéñéòéóéôéõéöé÷éøéùéúéûéüéýéþ)r›r¸rm)r¹rÈrn)rÉrÍrlrrrÚutf8c Cs| dd¡ ¡dkrtdƒ‚| ¡dkr0tdƒ‚g}d}d}|t|ƒkrò||}t|tƒsbt|ƒ}||jkr¦||jkr¦|j    D]&\}}    }
||kr|||    kr|||
7}qðq|q<|dkrè||j
krè|  |||…¡|  |j
|¡|d    7}|}q<|d    7}q<|dkr|S|  ||d
…¡d   |¡S) aFix characters from one encoding embedded in some other encoding.
 
        Currently the only situation supported is Windows-1252 (or its
        subset ISO-8859-1), embedded in UTF-8.
 
        :param in_bytes: A bytestring that you suspect contains
            characters from multiple encodings. Note that this _must_
            be a bytestring. If you've already converted the document
            to Unicode, you're too late.
        :param main_encoding: The primary encoding of `in_bytes`.
        :param embedded_encoding: The encoding that was used to embed characters
            in the main document.
        :return: A bytestring in which `embedded_encoding`
          characters have been converted to their `main_encoding`
          equivalents.
        r˜r—)rhÚ windows_1252zPWindows-1252 and ISO-8859-1 are the only currently supported embedded encodings.)rØrgz4UTF-8 is the only currently supported main encoding.rrrNó) rGrYÚNotImplementedErrorr%rrrrÚFIRST_MULTIBYTE_MARKERÚLAST_MULTIBYTE_MARKERÚMULTIBYTE_MARKERS_AND_SIZESÚWINDOWS_1252_TO_UTF8r‘r() rBZin_bytesZ main_encodingZembedded_encodingZ byte_chunksZ chunk_startÚposÚbyteÚstartÚendÚsizer r r Ú    detwingles@ÿ ÿ 
 
ÿ
 
zUnicodeDammit.detwingle)r)r)rØrh)rSrTrUrVršr’rdrŽr„r“rzr–rr™r‰r‡rßrÞrÜrÝrWrår r r r r{
s~    ÿýþ
X
 
 
 á%€ÿ †~ý  ÿr{)rVÚ __license__Ú html.entitiesrÚ collectionsrrœr,rÚstringrZcchardetÚ ImportErrorÚchardetZcharset_normalizerrZ xml_encodingZ    html_metaÚdictrtr-rˆrórsrrÚobjectrrXr{r r r r Ú<module>sH     
þ
  þ
 {N