Skip to content

Instantly share code, notes, and snippets.

@nurse
Last active December 14, 2015 04:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nurse/5027888 to your computer and use it in GitHub Desktop.
Save nurse/5027888 to your computer and use it in GitHub Desktop.
僕の考えた最強の Binary Pack 仕様

僕の考えた最強の Binary Pack 仕様

追加する format

  • annotation
  • bignum (多倍長整数)
  • decimal
  • rational
  • raw inf (64でいい?)
  • array inf (64でいい?)
  • map inf (64でいい?)

Annotation

次の値の高レイヤにおける意味を指定するもの。

具体的なフォーマット指定子は取る引数の数によって複数ある。2個なのは例えばレガシーエンコーディングの文字列において、エンコーディング名と本体とか。本体の方が後にくるので、annotationを無視したいときは最後のだけ読む。(TODO:本体が複数の場合はどうするんだ、map使うの?)

  • annotation1
  • annotation2

Well-known Annotation Directory

  • encoding
  • UTF-8
  • UTF-16BE
  • UTF-16LE
  • UTF-32BE
  • UTF-32LE
  • ASCII
  • ISO-8859-1 (latin1)
  • other encodings (まず直後にfix rawでencoding nameを与える)
  • datetime
  • typed array
  • typed map

Examples

  • [annotation1] [UTF-8] [fixraw] ...
  • [annotation2] [other encodings] [fixraw] ISO-2022-JP [fixraw] ESC ( B ...
  • [annotation1] [datetime] [rational] ...

bignum

多倍長整数です。

  • [bignum+] BER圧縮整数
  • [bignum-] BER圧縮整数

decimal

10進数。

  • IEEE 754 decimal32
  • IEEE 754 decimal64
  • IEEE 754 decimal128

rational

有理数。

  • [rational] [fixnum] [fixnum]

raw inf, array inf, map inf

長さの指定に BER 圧縮整数を用いる。

see also http://wiki.msgpack.org/display/MSGPACK/Format+specification

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment