CJam, 27 26 bytes
80qf{i2b7Te[4/~\)\@+++2bc}
Try it online!
Explanation
The Braille code points are neatly ordered so that the individual dots do count up in binary. However, the ordering of the bits in the code points is different. We want the following order:
04
15
26
37
Whereas the characters are laid out in Unicode in this order:
03
14
25
67
(Which kinda makes sense, because historically, Braille only used the first six dots.) Note that we don't need the 7
dot, since the input is guaranteed to be in the ASCII range. So given a list of bits [6 5 4 3 2 1 0]
of an input character, we want to reorder them into [3 6 5 4 2 1 0]
, to pull the bit representing the bottom-left dot to the most significant position.
80 e# Push 80... we'll need this later.
q e# Read all input.
f{ e# Map this block onto each character, putting a copy of the 80
e# below each character.
i e# Convert the character to its code point.
2b e# Get its binary representation.
7Te[ e# Pad it to 7 bits with zeros. We've now got some bit list
e# [6 5 4 3 2 1 0].
4/ e# Split into chunks of 4: [[6 5 4 3] [2 1 0]]
~ e# Dump them onto the stack: [6 5 4 3] [2 1 0]
\ e# Swap them: [2 1 0] [6 5 4 3]
) e# Pull off the last element: [2 1 0] [6 5 4] 3
\ e# Swap: [2 1 0] 3 [6 5 4]
@ e# Rotate: 3 [6 5 4] [2 1 0]
++ e# Concatenate twice: [3 6 5 4 2 1 0]
e# That's the reordering done.
+ e# Prepend the 80. That puts it in the 2^7 position of the
e# binary digit list, which gives it a value of 10240, which
e# is where the Braille characters start.
2b e# Convert the bits back to an integer.
c e# Convert the code point to the corresponding integer.
}%
a
is⠱
, not⠹
(which I think isq
)? \$\endgroup\$a
is⠱
. \$\endgroup\$⠹
would have been wrong either way, since it has the wrong number of punched cells. \$\endgroup\$