Skip to content

Instantly share code, notes, and snippets.

@Chunjee
Created August 31, 2020 00:50
Show Gist options
  • Save Chunjee/8f2d46ccff8e5129c411c07ae6239921 to your computer and use it in GitHub Desktop.
Save Chunjee/8f2d46ccff8e5129c411c07ae6239921 to your computer and use it in GitHub Desktop.
Braille Bytes (Big-endian)
;#! AHK v2.a122 64 Unicode ; UTF-16_LE_BOM
/*
∫⣿∫ Braille Bytes (Big-endian)
-----------------------------------------------------------------------------
⠢⡦⢆⢎⠞⠞⢖⠄⠢⣎⡖⢖⣦ ◷ 2020-08-26
Computers store information in various sized groups of binary bits.
If sometime you feel blind, use Braille Bytes to visualize.
• Braille Pattern Dots: U+2800 U+28FF
https://en.wikipedia.org/wiki/Braille_Patterns
• ON HOLY WARS AND A PLEA FOR PEACE
Who's on first? Zero or One ?? (Danny Cohen)
https://www.ietf.org/rfc/ien/ien137.txt
• ⓕ by FredOoo @ autohotkey.com/boards
• Examples :
Horizontal bars become vertical bars
byte -> 8765 4321 -> 8 4 -> ∫⣿∫ 1 -> 0000 0001 -> 0 0 -> ∫⢀∫
7 3 0 0
6 2 0 0
5 1 0 1
129 -> 1000 0001 -> 1 0 -> ∫⢁∫ 255 -> 1111 1111 -> 1 1 -> ∫⣿∫
0 0 1 1
0 0 1 1
0 1 1 1
256 -> 0000 0001 0000 0000 -> 0 0 0 0 -> ∫⢀⠀∫
0 0 0 0
0 0 0 0
0 1 0 0
65535 -> 1111 1111 1111 1111 -> 1 1 1 1 -> ∫⣿⣿∫
1 1 1 1
1 1 1 1
1 1 1 1
System 32-bit -> ⣿⣿⣿⣿ System 64-Bit -> ⣿⣿⣿⣿⣿⣿⣿⣿
ASCII -> ⣿ UTF-16 -> ⣿⣿ or more
⣾ ⣽ ⣻ ⢿ ⣷ ⣯ ⣟ ⡿ <- by Filling the missing bit,
2⁷ 2⁶ 2⁵ 2⁴ 2³ 2² 2¹ 2⁰ <| you Add this value to the entire byte
128 64 32 16 8 4 2 1 |
*/
;; Demo
;;======
¶ := "`n"
; Depending on your font, use full height brackets. (Here is maths integral)
; It might otherwise be difficult to judge the vertical alignment of the dots.
msgBox "0 -> ∫" BBytes( 0 ) "∫" ¶ ; -> ∫⠀∫
. "255 -> ∫" BBytes( 255 ) "∫" ¶ ; -> ∫⣿∫
. "65535 -> ∫" BBytes( 65535 ) "∫" ¶ ; -> ∫⣿⣿∫
. "65536 -> ∫" BBytes( 65536 ) "∫" ¶ ; -> ∫⢀⠀⠀∫
. "65 -> ∫" BBytes( 65 ) "∫" ¶ ; -> ∫⢂∫
. "A -> ∫" BBytes( ord("A") ) "∫" ¶ ; -> ∫⢂∫
. "本 -> ∫" BBytes( ord("本") ) "∫" ¶ ; -> ∫⢶⠜∫
. "軔 -> ∫" BBytes( ord("軔") ) "∫" ¶ ; -> ∫⠠⣏⡻∫ ; 2F9DE from Supplementary Ideographic Plane
, "Braille Byts"
BBytes( value ){
static BPD := map(
; Base ∫⠿∫
0 , 0 , 4 , 16 , 2 , 32 , 6 , 48 , ; ∫⠀⠐⠠⠰∫
128 , 1 , 132 , 17 , 130 , 33 , 134 , 49 , ; ∫⠁⠑⠡⠱∫
64 , 2 , 68 , 18 , 66 , 34 , 70 , 50 , ; ∫⠂⠒⠢⠲∫
192 , 3 , 196 , 19 , 194 , 35 , 198 , 51 , ; ∫⠃⠓⠣⠳∫
32 , 4 , 36 , 20 , 34 , 36 , 38 , 52 , ; ∫⠄⠔⠤⠴∫
160 , 5 , 164 , 21 , 162 , 37 , 166 , 53 , ; ∫⠅⠕⠥⠵∫
96 , 6 , 100 , 22 , 98 , 38 , 102 , 54 , ; ∫⠆⠖⠦⠶∫
224 , 7 , 228 , 23 , 226 , 39 , 230 , 55 , ; ∫⠇⠗⠧⠷∫
8 , 8 , 12 , 24 , 10 , 40 , 14 , 56 , ; ∫⠈⠘⠨⠸∫
136 , 9 , 140 , 25 , 138 , 41 , 142 , 57 , ; ∫⠉⠙⠩⠹∫
72 , 10 , 76 , 26 , 74 , 42 , 78 , 58 , ; ∫⠊⠚⠪⠺∫
200 , 11 , 204 , 27 , 202 , 43 , 206 , 59 , ; ∫⠋⠛⠫⠻∫
40 , 12 , 44 , 28 , 42 , 44 , 46 , 60 , ; ∫⠌⠜⠬⠼∫
168 , 13 , 172 , 29 , 170 , 45 , 174 , 61 , ; ∫⠍⠝⠭⠽∫
104 , 14 , 108 , 30 , 106 , 46 , 110 , 62 , ; ∫⠎⠞⠮⠾∫
232 , 15 , 236 , 31 , 234 , 47 , 238 , 63 , ; ∫⠏⠟⠯⠿∫
)
_ord( byte ){
; BPD order
base := byte & 238 ; ∫⠿∫
block := (byte&16==16) + (byte&1==1)*2 ; 0∫⠀∫ 1∫⡀∫ 2∫⢀∫ 3∫⣀∫
return BPD[ base ] + block*64
}
_code( byte ){
; BByte U+code
return 0x2800 + _ord( byte )
}
; BBytes Dots ⣿
result := ''
if type(value)="integer" && value>=0 {
if !value
return chr(_code( 0 )) ; ∫⠀∫
while value > 0 {
result := chr(_code( value & 0x00FF )) result
value >>= 8
}
return result
} else {
throw Exception("Error: Must use positive Integer value")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment