-
Notifications
You must be signed in to change notification settings - Fork 31
/
encoding.py
52 lines (39 loc) · 1.62 KB
/
encoding.py
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
import string
codepage = "λƛ¬∧⟑∨⟇÷׫\n»°•ß†€"
codepage += "½∆ø↔¢⌐æʀʁɾɽÞƈ∞¨ "
codepage += "!\"#$%&'()*+,-./01"
codepage += "23456789:;<=>?@A"
codepage += "BCDEFGHIJKLMNOPQ"
codepage += "RSTUVWXYZ[\\]^_`abc"
codepage += "defghijklmnopqrs"
codepage += "tuvwxyz{|}~↑↓∴∵›"
codepage += "‹∷¤ð→←βτȧḃċḋėḟġḣ"
codepage += "ḭŀṁṅȯṗṙṡṫẇẋẏż√⟨⟩"
codepage += "‛₀₁₂₃₄₅₆₇₈¶⁋§ε¡"
codepage += "∑¦≈µȦḂĊḊĖḞĠḢİĿṀṄ"
codepage += "ȮṖṘṠṪẆẊẎŻ₌₍⁰¹²∇⌈"
codepage += "⌊¯±₴…□↳↲⋏⋎꘍ꜝ℅≤≥"
codepage += "≠⁼ƒɖ∪∩⊍£¥⇧⇩ǍǎǏǐǑ"
codepage += "ǒǓǔ⁽‡≬⁺↵⅛¼¾Π„‟"
old_codepage = codepage.replace("^_`", "`^_")
assert len(codepage) == 256
def vyxal_to_utf8(code: list[int]) -> str:
"""Turn characters on Vyxal codepage into actual UTF-8 characters"""
# Taken from the old 05AB1E interpreter
processed_code = ""
for char in code:
processed_code += codepage[char]
return processed_code
def utf8_to_vyxal(code: str) -> str:
"""Turn UTF-8 characters into bytes according to the codepage"""
# Taken from the old 05AB1E interpreter
processed_code = ""
for char in code:
processed_code += chr(codepage.index(char))
return processed_code
compression = codepage
for char in string.printable:
compression = compression.replace(char, "")
codepage_number_compress = codepage.replace("»", "")
codepage_string_compress = codepage.replace("«", "")
base_27_alphabet = " abcdefghijklmnopqrstuvwxyz"