mò v Lc@sdZdZdZdZdkZdkZdklZlZdkZdfd„ƒYZ d„Z e d ƒZ e d ƒZ e d ƒZ e d ƒZe d ƒZe dƒZd„Zd„Zdd„Zd„Zdd„Zd„Zd„Zgdd„Zgdd„ZeidƒZd„Zd„Zd„Zdd„Z ei!dƒZ"d„Z#e$djo–d k%l&Z&d!k'l(Z(xye&d"D]iZ)e(e)ƒoVe*e)d#ƒZ+e+i,d$ƒZ-gZ.ee-e.ƒZ/e/o e)Ge/GHqöe0e.ƒGHqqWndS(%sa $Id$ This module deals with detecting XML encodings, using both BOMs and explicit declarations. s'Joseph Walton s $Revision$s Copyright (c) 2004 Joseph WaltonN(sObscureEncodingsNonstdEncodingt FailingCodeccBstZd„Zdd„ZRS(NcCs ||_dS(N(tnametself(RR((tD/web/script/rubys/feedvalidator.org/src/feedvalidator/xmlEncoding.pyt__init__ststrictcCstd|idƒ‚dS(NsNo codec available for s& in this installation of FeedValidator(t UnicodeErrorRR(Rttxtterrors((Rtfails(t__name__t __module__RR (((RRs cCs,yti|ƒSWnt|ƒiSnXdS(N(tcodecst getdecodertcodecRR (R((RR ssUTF-32BEsUTF-32LEsUTF-16BEsUTF-16LEtIBM037s ISO-8859-1cCs‘|idd|ƒd}|idd|ƒd}d}xB|||!D]3}|djo|ddd}qF|d7}qFW|d7}||fS(Ns iis i(Rtcounttidxtrowtrfindtlntcolumntc(RRRRRR((Rt _position+s  cCs|iddƒiddƒS(Ns s s (Rtreplace(R((Rt_normaliseNewlines7scCs6|o|\|id<|id (as of 2004-03-27)?sUS-ASCIIs ISO-8859-1sEUC-JPs ISO-8859-2s ISO-8859-15s ISO-8859-7sKOI8-Rt SHIFT_JISs WINDOWS-1250s WINDOWS-1251s WINDOWS-1252s WINDOWS-1254s WINDOWS-1255s WINDOWS-1256tGB18030N(R1R0R((R0((RtisCommonessUTF-8cCs¡|d }|djo)t|dtddddg|ƒ}n^|djo)t|dtddddg|ƒ}n(|djp |d jotd ƒ‚nþ|d d jo/t|d t d dddg|dd ƒ}n¾|d djo/t|d t d dddg|dd ƒ}n~|d djo&t|dt dg|ddƒ}nG|djo(t|tdddddg|ƒ}n|djo(t|tdddddg|ƒ}nÝ|djo(t|t dd dddg|ƒ}n¨|djo(t|t dd dddg|ƒ}ns|djo't t t |ƒdƒƒpd&}n?|d jo%t|td!d"d#d$g|ƒ}n |d%f}|S('sÈThis is the logic from appendix F.1 of the XML 1.0 specification. Pass in the start of a document (>= 256 octets), and receive the encoding to use, or None if there is a problem with the document.itþÿsUTF-32sISO-10646-UCS-4tCSUCS4sUCS-4sÿþtÿþsþÿs3Unable to process UCS-4 with unusual octet orderingisþÿsUTF-16sISO-10646-UCS-2t CSUNICODEsUCS-2R.sÿþissUTF-8tR?R@RARCRBRRR-R R,R/R1R4RDREtcompileRFR$ROR)R[t getencoderRbRcR tsystargvtos.pathtisfileR0topentftreadtltlogR%trepr('R%RbR$R1RpRRFREROR R,R[RjRURCRTRRuR RgR4RnR R/RcRRBRiRhR&R?RrRDR>RtR)R@R0RA((Rt?sX             )  E