Python codecs.latin_1_decode() Examples

The following are 30 code examples of codecs.latin_1_decode(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module codecs , or try the search function .
Example #1
Source File: _form.py    From BruteXSS with GNU General Public License v3.0 6 votes vote down vote up
def get_entitydefs():
    import htmlentitydefs
    from codecs import latin_1_decode
    entitydefs = {}
    try:
        htmlentitydefs.name2codepoint
    except AttributeError:
        entitydefs = {}
        for name, char in htmlentitydefs.entitydefs.items():
            uc = latin_1_decode(char)[0]
            if uc.startswith("&#") and uc.endswith(";"):
                uc = unescape_charref(uc[2:-1], None)
            entitydefs["&%s;" % name] = uc
    else:
        for name, codepoint in htmlentitydefs.name2codepoint.items():
            entitydefs["&%s;" % name] = unichr(codepoint)
    return entitydefs 
Example #2
Source File: _form.py    From pelisalacarta-ce with GNU General Public License v3.0 6 votes vote down vote up
def get_entitydefs():
    import htmlentitydefs
    from codecs import latin_1_decode
    entitydefs = {}
    try:
        htmlentitydefs.name2codepoint
    except AttributeError:
        entitydefs = {}
        for name, char in htmlentitydefs.entitydefs.items():
            uc = latin_1_decode(char)[0]
            if uc.startswith("&#") and uc.endswith(";"):
                uc = unescape_charref(uc[2:-1], None)
            entitydefs["&%s;" % name] = uc
    else:
        for name, codepoint in htmlentitydefs.name2codepoint.items():
            entitydefs["&%s;" % name] = unichr(codepoint)
    return entitydefs 
Example #3
Source File: clientform.py    From NoobSec-Toolkit with GNU General Public License v2.0 6 votes vote down vote up
def get_entitydefs():
    import htmlentitydefs
    from codecs import latin_1_decode
    entitydefs = {}
    try:
        htmlentitydefs.name2codepoint
    except AttributeError:
        entitydefs = {}
        for name, char in htmlentitydefs.entitydefs.items():
            uc = latin_1_decode(char)[0]
            if uc.startswith("&#") and uc.endswith(";"):
                uc = unescape_charref(uc[2:-1], None)
            entitydefs["&%s;" % name] = uc
    else:
        for name, codepoint in htmlentitydefs.name2codepoint.items():
            entitydefs["&%s;" % name] = unichr(codepoint)
    return entitydefs 
Example #4
Source File: clientform.py    From NoobSec-Toolkit with GNU General Public License v2.0 6 votes vote down vote up
def get_entitydefs():
    import htmlentitydefs
    from codecs import latin_1_decode
    entitydefs = {}
    try:
        htmlentitydefs.name2codepoint
    except AttributeError:
        entitydefs = {}
        for name, char in htmlentitydefs.entitydefs.items():
            uc = latin_1_decode(char)[0]
            if uc.startswith("&#") and uc.endswith(";"):
                uc = unescape_charref(uc[2:-1], None)
            entitydefs["&%s;" % name] = uc
    else:
        for name, codepoint in htmlentitydefs.name2codepoint.items():
            entitydefs["&%s;" % name] = unichr(codepoint)
    return entitydefs 
Example #5
Source File: clientform.py    From NoobSec-Toolkit with GNU General Public License v2.0 6 votes vote down vote up
def get_entitydefs():
    import htmlentitydefs
    from codecs import latin_1_decode
    entitydefs = {}
    try:
        htmlentitydefs.name2codepoint
    except AttributeError:
        entitydefs = {}
        for name, char in htmlentitydefs.entitydefs.items():
            uc = latin_1_decode(char)[0]
            if uc.startswith("&#") and uc.endswith(";"):
                uc = unescape_charref(uc[2:-1], None)
            entitydefs["&%s;" % name] = uc
    else:
        for name, codepoint in htmlentitydefs.name2codepoint.items():
            entitydefs["&%s;" % name] = unichr(codepoint)
    return entitydefs 
Example #6
Source File: clientform.py    From NoobSec-Toolkit with GNU General Public License v2.0 6 votes vote down vote up
def get_entitydefs():
    import htmlentitydefs
    from codecs import latin_1_decode
    entitydefs = {}
    try:
        htmlentitydefs.name2codepoint
    except AttributeError:
        entitydefs = {}
        for name, char in htmlentitydefs.entitydefs.items():
            uc = latin_1_decode(char)[0]
            if uc.startswith("&#") and uc.endswith(";"):
                uc = unescape_charref(uc[2:-1], None)
            entitydefs["&%s;" % name] = uc
    else:
        for name, codepoint in htmlentitydefs.name2codepoint.items():
            entitydefs["&%s;" % name] = unichr(codepoint)
    return entitydefs 
Example #7
Source File: test_codecs.py    From Fluid-Designer with GNU General Public License v3.0 6 votes vote down vote up
def test_decode_unicode(self):
        # Most decoders don't accept unicode input
        decoders = [
            codecs.utf_7_decode,
            codecs.utf_8_decode,
            codecs.utf_16_le_decode,
            codecs.utf_16_be_decode,
            codecs.utf_16_ex_decode,
            codecs.utf_32_decode,
            codecs.utf_32_le_decode,
            codecs.utf_32_be_decode,
            codecs.utf_32_ex_decode,
            codecs.latin_1_decode,
            codecs.ascii_decode,
            codecs.charmap_decode,
        ]
        if hasattr(codecs, "mbcs_decode"):
            decoders.append(codecs.mbcs_decode)
        for decoder in decoders:
            self.assertRaises(TypeError, decoder, "xxx") 
Example #8
Source File: clientform.py    From POC-EXP with GNU General Public License v3.0 6 votes vote down vote up
def get_entitydefs():
    import htmlentitydefs
    from codecs import latin_1_decode
    entitydefs = {}
    try:
        htmlentitydefs.name2codepoint
    except AttributeError:
        entitydefs = {}
        for name, char in htmlentitydefs.entitydefs.items():
            uc = latin_1_decode(char)[0]
            if uc.startswith("&#") and uc.endswith(";"):
                uc = unescape_charref(uc[2:-1], None)
            entitydefs["&%s;" % name] = uc
    else:
        for name, codepoint in htmlentitydefs.name2codepoint.items():
            entitydefs["&%s;" % name] = unichr(codepoint)
    return entitydefs 
Example #9
Source File: clientform.py    From EasY_HaCk with Apache License 2.0 6 votes vote down vote up
def get_entitydefs():
    import htmlentitydefs
    from codecs import latin_1_decode
    entitydefs = {}
    try:
        htmlentitydefs.name2codepoint
    except AttributeError:
        entitydefs = {}
        for name, char in htmlentitydefs.entitydefs.items():
            uc = latin_1_decode(char)[0]
            if uc.startswith("&#") and uc.endswith(";"):
                uc = unescape_charref(uc[2:-1], None)
            entitydefs["&%s;" % name] = uc
    else:
        for name, codepoint in htmlentitydefs.name2codepoint.items():
            entitydefs["&%s;" % name] = unichr(codepoint)
    return entitydefs 
Example #10
Source File: test_codecs.py    From ironpython3 with Apache License 2.0 6 votes vote down vote up
def test_decode_unicode(self):
        # Most decoders don't accept unicode input
        decoders = [
            codecs.utf_7_decode,
            codecs.utf_8_decode,
            codecs.utf_16_le_decode,
            codecs.utf_16_be_decode,
            codecs.utf_16_ex_decode,
            codecs.utf_32_decode,
            codecs.utf_32_le_decode,
            codecs.utf_32_be_decode,
            codecs.utf_32_ex_decode,
            codecs.latin_1_decode,
            codecs.ascii_decode,
            codecs.charmap_decode,
        ]
        if hasattr(codecs, "mbcs_decode"):
            decoders.append(codecs.mbcs_decode)
        for decoder in decoders:
            self.assertRaises(TypeError, decoder, "xxx") 
Example #11
Source File: test_codecs.py    From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 6 votes vote down vote up
def test_decode_unicode(self):
        # Most decoders don't accept unicode input
        decoders = [
            codecs.utf_7_decode,
            codecs.utf_8_decode,
            codecs.utf_16_le_decode,
            codecs.utf_16_be_decode,
            codecs.utf_16_ex_decode,
            codecs.utf_32_decode,
            codecs.utf_32_le_decode,
            codecs.utf_32_be_decode,
            codecs.utf_32_ex_decode,
            codecs.latin_1_decode,
            codecs.ascii_decode,
            codecs.charmap_decode,
        ]
        if hasattr(codecs, "mbcs_decode"):
            decoders.append(codecs.mbcs_decode)
        for decoder in decoders:
            self.assertRaises(TypeError, decoder, "xxx") 
Example #12
Source File: latin_1.py    From datafari with Apache License 2.0 5 votes vote down vote up
def decode(self, input, final=False):
        return codecs.latin_1_decode(input,self.errors)[0] 
Example #13
Source File: latin_1.py    From medicare-demo with Apache License 2.0 5 votes vote down vote up
def decode(self, input, final=False):
        return codecs.latin_1_decode(input,self.errors)[0] 
Example #14
Source File: latin_1.py    From syntheticmass with Apache License 2.0 5 votes vote down vote up
def decode(self, input, final=False):
        return codecs.latin_1_decode(input,self.errors)[0] 
Example #15
Source File: latin_1.py    From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 5 votes vote down vote up
def decode(self, input, final=False):
        return codecs.latin_1_decode(input,self.errors)[0] 
Example #16
Source File: latin_1.py    From PhonePi_SampleServer with MIT License 5 votes vote down vote up
def decode(self, input, final=False):
        return codecs.latin_1_decode(input,self.errors)[0] 
Example #17
Source File: ttfonts.py    From stdm with GNU General Public License v2.0 5 votes vote down vote up
def latin1_to_utf8(text):
    "helper to convert when needed from latin input"
    return utf_8_encode(latin_1_decode(text)[0])[0] 
Example #18
Source File: latin_1.py    From Splunking-Crime with GNU Affero General Public License v3.0 5 votes vote down vote up
def decode(self, input, final=False):
        return codecs.latin_1_decode(input,self.errors)[0] 
Example #19
Source File: html2text.py    From PyDataset with MIT License 5 votes vote down vote up
def name2cp(k):
    if k == 'apos': return ord("'")
    if hasattr(htmlentitydefs, "name2codepoint"): # requires Python 2.3
        return htmlentitydefs.name2codepoint[k]
    else:
        k = htmlentitydefs.entitydefs[k]
        if k.startswith("&#") and k.endswith(";"): return int(k[2:-1]) # not in latin-1
        return ord(codecs.latin_1_decode(k)[0]) 
Example #20
Source File: latin_1.py    From odoo13-x64 with GNU General Public License v3.0 5 votes vote down vote up
def decode(self, input, final=False):
        return codecs.latin_1_decode(input,self.errors)[0] 
Example #21
Source File: latin_1.py    From CTFCrackTools-V2 with GNU General Public License v3.0 5 votes vote down vote up
def decode(self, input, final=False):
        return codecs.latin_1_decode(input,self.errors)[0] 
Example #22
Source File: latin_1.py    From CTFCrackTools-V2 with GNU General Public License v3.0 5 votes vote down vote up
def decode(self, input, final=False):
        return codecs.latin_1_decode(input,self.errors)[0] 
Example #23
Source File: html2text.py    From RedditBots with MIT License 5 votes vote down vote up
def name2cp(k):
    if k == 'apos': return ord("'")
    if hasattr(htmlentitydefs, "name2codepoint"): # requires Python 2.3
        return htmlentitydefs.name2codepoint[k]
    else:
        k = htmlentitydefs.entitydefs[k]
        if k.startswith("&#") and k.endswith(";"): return int(k[2:-1]) # not in latin-1
        return ord(codecs.latin_1_decode(k)[0]) 
Example #24
Source File: latin_1.py    From RevitBatchProcessor with GNU General Public License v3.0 5 votes vote down vote up
def decode(self, input, final=False):
        return codecs.latin_1_decode(input,self.errors)[0] 
Example #25
Source File: latin_1.py    From Carnets with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def decode(self, input, final=False):
        return codecs.latin_1_decode(input,self.errors)[0] 
Example #26
Source File: latin_1.py    From PokemonGo-DesktopMap with MIT License 5 votes vote down vote up
def decode(self, input, final=False):
        return codecs.latin_1_decode(input,self.errors)[0] 
Example #27
Source File: latin_1.py    From unity-python with MIT License 5 votes vote down vote up
def decode(self, input, final=False):
        return codecs.latin_1_decode(input,self.errors)[0] 
Example #28
Source File: latin_1.py    From android_universal with MIT License 5 votes vote down vote up
def decode(self, input, final=False):
        return codecs.latin_1_decode(input,self.errors)[0] 
Example #29
Source File: latin_1.py    From canape with GNU General Public License v3.0 5 votes vote down vote up
def decode(self, input, final=False):
        return codecs.latin_1_decode(input,self.errors)[0] 
Example #30
Source File: latin_1.py    From CTFCrackTools with GNU General Public License v3.0 5 votes vote down vote up
def decode(self, input, final=False):
        return codecs.latin_1_decode(input,self.errors)[0]