LoginSignup
5
5

More than 5 years have passed since last update.

base64の次はbase65536が来る!!...こないかな?

Posted at

※ この記事は自分のブログ記事のダイジェスト版(?)です。
http://blog.code42.jp/base65536go

base65536がおもしろかったのでGoでもやってみた

githubでfernoって人がbase65536というアイディアを出していて、nodejsのライブラリを作ってた。
https://github.com/ferno/base65536

base65536って何?

ところでbase65336ってなんだろう?

引用:

Base64 is used to encode arbitrary binary data as "plain" text using a small, extremely safe repertoire of 64 (well, 65) characters. Base64 remains highly suited to text systems where the range of characters available is very small -- i.e., anything still constrained to plain ASCII. Base64 encodes 6 bits, or 3/4 of an octet, per character.
However, now that Unicode rules the world, the range of characters which can be considered "safe" in this way is, in many situations, significantly wider. Base65536 applies the same basic principle to a carefully-chosen repertoire of 65,536 (well, 65,792) Unicode code points, encoding 16 bits, or 2 octets, per character. This allows up to 280 octets of binary data to fit in a Tweet.

わからん!!
でも、base64(64種類の文字)でやってたことをunicode(65536種類のコードポイント)でやるってことらしい!!

(´ε`;)ウーン ...
( ー`дー´)キリッ エンコードで使う文字のバラエティが増えるってことね(ざっくり)

つくってみた

encode
s := "hello world"
result := base65536.Encode(s)

Println(result)
// 驨ꍬ啯𒁷ꍲᕤ
decode
s := "驨ꍬ啯𒁷ꍲᕤ"

result := base65536.Decode(s)
Println(result)
// hello world
5
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
5