Skip to content

Commit

Permalink
More work on EuroBraille
Browse files Browse the repository at this point in the history
1. There are some problems with spacing
2. I used latex-symbols.htm to scrape LaTeX <=> Unicode symbols, but it has problems. Need to look elsewhere or do a lot of cleanup
  • Loading branch information
NSoiffer committed Feb 21, 2024
1 parent 4b5c445 commit 1bf32e2
Show file tree
Hide file tree
Showing 10 changed files with 2,554 additions and 447 deletions.
32 changes: 31 additions & 1 deletion PythonScripts/ascii_braille.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def u2a(unicode:str):

ASCII_TO_UNICODE = "⠀⠮⠐⠼⠫⠩⠯⠄⠷⠾⠡⠬⠠⠤⠨⠌⠴⠂⠆⠒⠲⠢⠖⠶⠦⠔⠱⠰⠣⠿⠜⠹⠈⠁⠃⠉⠙⠑⠋⠛⠓⠊⠚⠅⠇⠍⠝⠕⠏⠟⠗⠎⠞⠥⠧⠺⠭⠽⠵⠪⠳⠻⠘⠸"
def ascii_to_unicode(ascii: str):
result = "";
result = ""
ascii = ascii.upper()
for ch in ascii:
i = ord(ch) - 32
Expand All @@ -48,6 +48,36 @@ def generate_ascii_to_unicode():
result += ch
print(result)

import json


def read_euro_braille_file() -> dict[str, str]:
# I had to purge the control chars from the file because I was getting an error like:
# json.decoder.JSONDecodeError: Invalid \escape: line 12 column 4 (char 125)
with open("euro-braille-dict.txt", 'r', encoding='utf8') as in_stream:
return json.loads(in_stream.read(), strict=True)


ASCII_TO_EURO_BRAILLE: dict[str, str] = read_euro_braille_file()


def ascii_to_euro_braille(ascii: str):
result = ""
for ch in ascii:
result += ASCII_TO_EURO_BRAILLE.get(ch)
return result


def a2eb(ascii: str):
return ascii_to_euro_braille(ascii)


def a2eb_loop():
text = input("text: ")
while text != "":
print(ascii_to_euro_braille(text))
text = input("text: ")


# Major hack
# ONCE PDF uses a mapping that seems to be based on the Spanish char encoding. This is a bit like ASCII braille, but different
Expand Down
Loading

0 comments on commit 1bf32e2

Please sign in to comment.