Created
February 5, 2020 16:20
-
-
Save 20chan/0c2c890072067fee8475a15a6ee10c42 to your computer and use it in GitHub Desktop.
python custom codec meta programming post example aheui code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import codecs, io, encodings | |
from encodings import utf_8 | |
aheui_code = ''' | |
''' | |
def aheui_decode(input, errors="strict"): | |
raw = bytes(input).decode("utf-8") | |
code = "\n".join(raw.splitlines()[1:]) | |
hooked = aheui_code + f'eval("""{code}""")' | |
return hooked, len(input) | |
def search_function(encoding): | |
if encoding != "aheui": | |
return None | |
utf8 = encodings.search_function("utf8") | |
return codecs.CodecInfo( | |
name="aheui", | |
encode=utf8.encode, | |
decode=aheui_decode, | |
) | |
codecs.register(search_function) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import register | |
import script |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: aheui | |
밤밣따빠밣밟따뿌 | |
빠맣파빨받밤뚜뭏 | |
돋밬탕빠맣붏두붇 | |
볻뫃박발뚷투뭏붖 | |
뫃도뫃희멓뭏뭏붘 | |
뫃봌토범더벌뿌뚜 | |
뽑뽀멓멓더벓뻐뚠 | |
뽀덩벐멓뻐덕더벅 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment