def explain_unicode(text): """ A utility method that's useful for debugging mysterious Unicode. It breaks down a string, showing you for each codepoint its number in hexadecimal, its glyph, its category in the Unicode standard, and its name in the Unicode standard. >>> explain_unicode('(╯°□°)╯︵ ┻━┻') U+0028 ( [Ps] LEFT PARENTHESIS U+256F ╯ [So] BOX DRAWINGS LIGHT ARC UP AND LEFT U+00B0 ° [So] DEGREE SIGN U+25A1 □ [So] WHITE SQUARE U+00B0 ° [So] DEGREE SIGN U+0029 ) [Pe] RIGHT PARENTHESIS U+256F ╯ [So] BOX DRAWINGS LIGHT ARC UP AND LEFT U+FE35 ︵ [Ps] PRESENTATION FORM FOR VERTICAL LEFT PARENTHESIS U+0020 [Zs] SPACE U+253B ┻ [So] BOX DRAWINGS HEAVY UP AND HORIZONTAL U+2501 ━ [So] BOX DRAWINGS HEAVY HORIZONTAL U+253B ┻ [So] BOX DRAWINGS HEAVY UP AND HORIZONTAL """ for char in text: if is_printable(char): display = char else: display = char.encode('unicode-escape').decode('ascii') print('U+{code:04X} {display} [{category}] {name}'.format( display=display_ljust(display, 7), code=ord(char), category=unicodedata.category(char), name=unicodedata.name(char, '<unknown>')))
def explain_unicode(text): """ A utility method that's useful for debugging mysterious Unicode. It breaks down a string, showing you for each codepoint its number in hexadecimal, its glyph, its category in the Unicode standard, and its name in the Unicode standard. >>> explain_unicode('(╯°□°)╯︵ ┻━┻') U+0028 ( [Ps] LEFT PARENTHESIS U+256F ╯ [So] BOX DRAWINGS LIGHT ARC UP AND LEFT U+00B0 ° [So] DEGREE SIGN U+25A1 □ [So] WHITE SQUARE U+00B0 ° [So] DEGREE SIGN U+0029 ) [Pe] RIGHT PARENTHESIS U+256F ╯ [So] BOX DRAWINGS LIGHT ARC UP AND LEFT U+FE35 ︵ [Ps] PRESENTATION FORM FOR VERTICAL LEFT PARENTHESIS U+0020 [Zs] SPACE U+253B ┻ [So] BOX DRAWINGS HEAVY UP AND HORIZONTAL U+2501 ━ [So] BOX DRAWINGS HEAVY HORIZONTAL U+253B ┻ [So] BOX DRAWINGS HEAVY UP AND HORIZONTAL """ for char in text: if is_printable(char): display = char else: display = char.encode('unicode-escape').decode('ascii') print('U+{code:04X} {display} [{category}] {name}'.format( display=display_ljust(display, 7), code=ord(char), category=unicodedata.category(char), name=unicodedata.name(char, '<unknown>') ))
def TestInput(data): if len(data) < 1: return fdp = atheris.FuzzedDataProvider(data) ftfy.character_width(chr(fdp.ConsumeIntInRange(1,1114110))) ftfy.monospaced_width(fdp.ConsumeString(1000)) ftfy.monospaced_width(fdp.ConsumeUnicode(1000)) choice = fdp.ConsumeIntInRange(1,3) if choice == 1: ftfy.display_ljust(fdp.ConsumeString(1000),fdp.ConsumeIntInRange(1,2000)) ftfy.display_ljust(fdp.ConsumeUnicode(1000),fdp.ConsumeIntInRange(1,2000)) if choice == 2: ftfy.display_rjust(fdp.ConsumeString(1000),fdp.ConsumeIntInRange(1,2000)) ftfy.display_rjust(fdp.ConsumeUnicode(1000),fdp.ConsumeIntInRange(1,2000)) if choice == 3: ftfy.display_center(fdp.ConsumeString(1000),fdp.ConsumeIntInRange(1,2000)) ftfy.display_center(fdp.ConsumeUnicode(1000),fdp.ConsumeIntInRange(1,2000)) fixes.remove_bom(fdp.ConsumeString(1000)) fixes.remove_bom(fdp.ConsumeUnicode(1000))