Created
April 12, 2014 20:38
-
-
Save letanure/10555668 to your computer and use it in GitHub Desktop.
text to braille
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
var brailleTable = { | |
'1': '⠼⠁', | |
'2': '⠼⠃', | |
'3': '⠼⠉', | |
'4': '⠼⠙', | |
'5': '⠼⠑', | |
'6': '⠼⠋', | |
'7': '⠼⠛', | |
'8': '⠼⠓', | |
'9': '⠼⠊', | |
'0': '⠼⠚', | |
'A': '⠠⠁', | |
'B': '⠠⠃', | |
'C': '⠠⠉', | |
'D': '⠠⠙', | |
'E': '⠠⠑', | |
'F': '⠠⠋', | |
'G': '⠠⠛', | |
'H': '⠠⠓', | |
'I': '⠠⠊', | |
'J': '⠠⠚', | |
'K': '⠠⠅', | |
'L': '⠠⠇', | |
'M': '⠠⠍', | |
'N': '⠠⠝', | |
'O': '⠠⠕', | |
'P': '⠠⠏', | |
'Q': '⠠⠟', | |
'R': '⠠⠗', | |
'S': '⠠⠎', | |
'T': '⠠⠞', | |
'U': '⠠⠥', | |
'V': '⠠⠧', | |
'W': '⠠⠺', | |
'X': '⠠⠭', | |
'Y': '⠠⠽', | |
'Z': '⠠⠵', | |
'a': '⠁', | |
'b': '⠃', | |
'c': '⠉', | |
'd': '⠙', | |
'e': '⠑', | |
'f': '⠋', | |
'g': '⠛', | |
'h': '⠓', | |
'i': '⠊', | |
'j': '⠚', | |
'k': '⠅', | |
'l': '⠇', | |
'm': '⠍', | |
'n': '⠝', | |
'o': '⠕', | |
'p': '⠏', | |
'q': '⠟', | |
'r': '⠗', | |
's': '⠎', | |
't': '⠞', | |
'u': '⠥', | |
'v': '⠧', | |
'w': '⠺', | |
'x': '⠭', | |
'y': '⠽', | |
'z': '⠵', | |
'\\.': '⠲', | |
',': '⠂', | |
'\\?': '⠦', | |
';': '⠆', | |
'!': '⠖', | |
'<': '⠦', | |
'>': '⠴', | |
'\\ ': '⠶', | |
'-': '⠤', | |
"'": '⠄', | |
} | |
function convertToBraille(text){ | |
var brailleText = ''; | |
for (var i = 0; i < text.length; i++) { | |
brailleText += brailleTable(text[i]) | |
}; | |
return brailleText; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
brailleTable(text[i])
should bebrailleTable[text[i]];
and why are there backslashes in the brailleTable? It only reads a single character in the for-loop. You could also dotext.split("").map(c=>brailleTable[c]).join("");
.