mojibake
is a script to "mojibake"-ify binary data so that it can be copy/pasted between (unicode-aware) terminals
The base64 format was designed to encode binary data within a set of characters that were safe for (text-only) e-mail. It was designed to be reasonably efficient -- each 8-bit base64 character can represent 6 bits of binary data. Or, 4 base64 characters represent 3 bytes of binary data.
Instead of optimizing for an efficient size transformations, what if you optimize for how many bytes you can represent in each character? Unicode has over 2^16 assigned characters, so you could represent two bytes per character!
It's not very space efficient, though. Those two bytes of binary data need 4-5 UTF-8 bytes to encode them as a unicode character.
But it looks cool!
$ date | base64
U3VuIE5vdiAgMiAxNjozNToxNCBHTVQgMjAxNAo=
$ date | mojibake
๐ฅต๐ฆธ ๐คนฏ๐ง ๐ขฒ๐ขฑ๐ฃบ๐ฃต๐ฃจฑ๐ฃ ๐ค๐ฅ ๐ฃฐ๐ฃด๋ฆ
Look at all the characters you saved! :p
$ echo ๐ฅต๐ฆธ ๐คนฏ๐ง ๐ขฒ๐ขฑ๐ฃบ๐ฃต๐ฃจฑ๐ฃ ๐ค๐ฅ ๐ฃฐ๐ฃด๋ฆ | ./mojibake --decode
Sun Nov 2 16:35:17 GMT 2014
When I'm ssh-hopping around on machines, sometimes I just want to copy-paste a couple small script files somewhere. Sometimes I use tar cz foo bar | base64
to grab them. But it's even easier with mojibake:
$ mojibake foo bar
๐ฅ๐ ๐ก๐ ๐ ้ญ๐ฆ
๐ ๐ ๐ ๐ ๐ ธ๐ ๐ ๐กฐ๐ฆฏ๐ฆฝ๐ฅ๐ ๐ค๐ฅ๐จ๐ฅ๐งธ๐ ฌ๐ ้ฐช๐ ๐ ๐ ๐ ณ๐คฃ็ฒ็นบ๐ขฃ๐ขฟ๐คฅ่ฌซ๐ ๐คฌ
๐ ไนพ๐งฌ๐ ๐ ๐ ๐ ๐คฌ๐ ๐ ๐ ๐ ๐จข๐ค๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ข๐ฆ
ฒ๐ฅ๐ ค๐ ฒ๐ฅน๐ฅ๐ฅน๐ฅต๐ง ๐ ๐ ต๐ ๐ ๐ก๐ ๐ขๅ ถ๐จฐ
๐ ฐๆ๐ขฅพ๐ ๐ขฑ๐ค
๐ ๐กณ๐ฅ๐ชธ๐ขฃซ๐ก้ถ๐จๅ๐ ฉ๐ฉฌ๐จ๐คไธ๐ค๐ฅๆง๐ฅชป๐คนพ๐ค ๐จฆๅ ค๐ข๐ ต๐งฒ๐ ทฎ๐ง็ ๐
๐คฌ๐ ขฃ๐ฅค้ด๐
๐ ๐ ๐ ๐คฌ๐ ๐ ๐ ๐ ๐ ฏ๐จข๐คไนพ๐งฌ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ค๐จ๐ ๐ ฆ๐ฆฝฏ๐ฅ๐ ๐ ๐ฅน๐ฅต๐ง ๐ ๐ ต๐ ๐ ๐ก๐ ๐ฅ
๐ ๐กธ๐ก๐ ๐ ๐ ฆ
๐ฆ
๐ช๐ ฐ๐คฌ๐ ๐ฅ๐ ๐ ๐ก ๐ ๐ ๐ ๐ ๐ช๐ฅด๐ ๐ฆก๐ง๐ฅ
๐ ๐ง๐ฅ๐งธ๐ ฌ๐ ้ฐช๐ ๐ ๐ ๐ ๐คฌ
๐ ๐ ๐
๐ ๐ ๐ ๐ ต๐ ๐ ๋
Then, on my destination machine:
$ mojibake --unzip
Paste the mojibaked zip file. Type '.' to finish.
๐ฅ๐ ๐ก๐ ๐ ้ญ๐ฆ
๐ ๐ ๐ ๐ ๐ ธ๐ ๐ ๐กฐ๐ฆฏ๐ฆฝ๐ฅ๐ ๐ค๐ฅ๐จ๐ฅ๐งธ๐ ฌ๐ ้ฐช๐ ๐ ๐ ๐ ณ๐คฃ็ฒ็นบ๐ขฃ๐ขฟ๐คฅ่ฌซ๐ ๐คฌ
๐ ไนพ๐งฌ๐ ๐ ๐ ๐ ๐คฌ๐ ๐ ๐ ๐ ๐จข๐ค๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ข๐ฆ
ฒ๐ฅ๐ ค๐ ฒ๐ฅน๐ฅ๐ฅน๐ฅต๐ง ๐ ๐ ต๐ ๐ ๐ก๐ ๐ขๅ ถ๐จฐ
๐ ฐๆ๐ขฅพ๐ ๐ขฑ๐ค
๐ ๐กณ๐ฅ๐ชธ๐ขฃซ๐ก้ถ๐จๅ๐ ฉ๐ฉฌ๐จ๐คไธ๐ค๐ฅๆง๐ฅชป๐คนพ๐ค ๐จฆๅ ค๐ข๐ ต๐งฒ๐ ทฎ๐ง็ ๐
๐คฌ๐ ขฃ๐ฅค้ด๐
๐ ๐ ๐ ๐คฌ๐ ๐ ๐ ๐ ๐ ฏ๐จข๐คไนพ๐งฌ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ค๐จ๐ ๐ ฆ๐ฆฝฏ๐ฅ๐ ๐ ๐ฅน๐ฅต๐ง ๐ ๐ ต๐ ๐ ๐ก๐ ๐ฅ
๐ ๐กธ๐ก๐ ๐ ๐ ฆ
๐ฆ
๐ช๐ ฐ๐คฌ๐ ๐ฅ๐ ๐ ๐ก ๐ ๐ ๐ ๐ ๐ช๐ฅด๐ ๐ฆก๐ง๐ฅ
๐ ๐ง๐ฅ๐งธ๐ ฌ๐ ้ฐช๐ ๐ ๐ ๐ ๐คฌ
๐ ๐ ๐
๐ ๐ ๐ ๐ ต๐ ๐ ๋
.Archive: /var/folders/h6/y72jsht13xx_0sgnrnb3m68c0000gn/T/tmp7yidcl5k.zip
inflating: foo
inflating: bar
If you want to see the cool chinese characters instead of a screen full of boxes, you'll need to install fonts that support the unicode CJK Unified Ideographs Extension B. You may already have a font that can handle these characters. If not, I recommend the freely available Hanazono.