Last active
December 28, 2015 21:58
-
-
Save HairyFotr/7567945 to your computer and use it in GitHub Desktop.
Give it a bit-string, and get out a UTF Braille rendering, e.g. https://en.wikipedia.org/wiki/Arecibo_message#Message_as_binary_string.5B4.5D
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
def encode(a: String, zero: Char = '0'): String = { | |
val bits = a.split("\n").map { line => line.map { _ != zero }.toArray } | |
val offsets = Array.ofDim[Int](bits.size/4+1, bits.head.size/2+1) | |
for(i <- 0 until bits.size; j <- 0 until bits.head.size) if(bits(i)(j)) offsets(i/4)(j/2) += (if(i%4 == 3) 0x40*(j%2 + 1) else math.pow(2, i%4 + (j%2)*3).toInt) | |
offsets.map { row => row.map { off => Character.toChars(0x2800 + off).head }.mkString }.mkString("\n") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
⡄⡂⡆⡁⡅⡃⡇⡠⢠⠄⡢⠀
⠀⠀⠀⠀⠀⣤⢲⠀⠀⠀⠀⠀
⣀⠀⠀⣀⡘⠚⣚⠀⠀⣀⠀⠀
⠷⠴⠄⠴⠦⠄⠶⠭⠄⠷⠴⠄
⣀⣈⡄⠀⠀⠀⠀⠀⠀⣀⣈⡄
⣖⢀⠀⠒⣄⠀⢒⣂⠀⣖⢀⠀
⠉⠩⠁⠉⠉⣥⠉⠉⠁⠉⠩⠁
⠒⡒⠃⠀⠀⢿⠀⠀⠀⠒⡒⠃
⠀⠈⠒⠤⠀⣻⠀⣀⠤⠊⠀⠀
⠀⡠⠒⠉⠀⣞⠀⠀⠉⠢⡀⠀
⠘⢄⠀⠀⠀⠝⠀⠀⣀⠔⠁⠀
⠀⡆⠉⠒⣂⣆⡒⠉⠀⠀⠀⠀
⠄⠥⠄⠊⢸⢿⠈⠂⢱⣟⢾⡇
⠀⠇⠀⠀⠼⠸⠄⠀⠘⠋⠉⠁
⠀⠿⠇⠂⠂⠁⠂⡆⡆⠆⠆⠂
⠀⢀⡤⠖⠛⠛⠓⠦⣄⠀⠀⠀
⢰⠋⢸⠢⡀⠀⡠⢺⠈⢳⠀⠀
⠀⠀⠸⢀⠈⡊⡀⠸⠀⠀⠀⠀
⠈⠉⠁⠈⠉⠉⠈⠀⠉⠉⠀⠀