[279] | 1 | mruby-pack (pack / unpack)
|
---|
| 2 | =========
|
---|
| 3 |
|
---|
| 4 | mruby-pack provides `Array#pack` and `String#unpack` for mruby.
|
---|
| 5 |
|
---|
| 6 |
|
---|
| 7 | ## Installation
|
---|
| 8 | Add the line below into your `build_config.rb`:
|
---|
| 9 |
|
---|
| 10 | ```
|
---|
| 11 | conf.gem :github => 'iij/mruby-pack'
|
---|
| 12 | ```
|
---|
| 13 |
|
---|
| 14 | There is no dependency on other mrbgems.
|
---|
| 15 |
|
---|
| 16 |
|
---|
| 17 | ## Supported template string
|
---|
| 18 | - A : arbitrary binary string (space padded, count is width)
|
---|
| 19 | - a : arbitrary binary string (null padded, count is width)
|
---|
| 20 | - C : 8-bit unsigned (unsigned char)
|
---|
| 21 | - c : 8-bit signed (signed char)
|
---|
| 22 | - D, d: 64-bit float, native format
|
---|
| 23 | - E : 64-bit float, little endian byte order
|
---|
| 24 | - e : 32-bit float, little endian byte order
|
---|
| 25 | - F, f: 32-bit float, native format
|
---|
| 26 | - G : 64-bit float, network (big-endian) byte order
|
---|
| 27 | - g : 32-bit float, network (big-endian) byte order
|
---|
| 28 | - H : hex string (high nibble first)
|
---|
| 29 | - h : hex string (low nibble first)
|
---|
| 30 | - I : unsigned integer, native endian (`unsigned int` in C)
|
---|
| 31 | - i : signed integer, native endian (`int` in C)
|
---|
| 32 | - L : 32-bit unsigned, native endian (`uint32_t`)
|
---|
| 33 | - l : 32-bit signed, native endian (`int32_t`)
|
---|
| 34 | - m : base64 encoded string (see RFC 2045, count is width)
|
---|
| 35 | - N : 32-bit unsigned, network (big-endian) byte order
|
---|
| 36 | - n : 16-bit unsigned, network (big-endian) byte order
|
---|
| 37 | - Q : 64-bit unsigned, native endian (`uint64_t`)
|
---|
| 38 | - q : 64-bit signed, native endian (`int64_t`)
|
---|
| 39 | - S : 16-bit unsigned, native endian (`uint16_t`)
|
---|
| 40 | - s : 16-bit signed, native endian (`int16_t`)
|
---|
| 41 | - V : 32-bit unsigned, VAX (little-endian) byte order
|
---|
| 42 | - v : 16-bit unsigned, VAX (little-endian) byte order
|
---|
| 43 | - Z : same as "a", except that null is added with *
|
---|
| 44 |
|
---|
| 45 |
|
---|
| 46 | ## License
|
---|
| 47 |
|
---|
| 48 | Copyright (c) 2012 Internet Initiative Japan Inc.
|
---|
| 49 |
|
---|
| 50 | Permission is hereby granted, free of charge, to any person obtaining a
|
---|
| 51 | copy of this software and associated documentation files (the "Software"),
|
---|
| 52 | to deal in the Software without restriction, including without limitation
|
---|
| 53 | the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
---|
| 54 | and/or sell copies of the Software, and to permit persons to whom the
|
---|
| 55 | Software is furnished to do so, subject to the following conditions:
|
---|
| 56 |
|
---|
| 57 | The above copyright notice and this permission notice shall be included in
|
---|
| 58 | all copies or substantial portions of the Software.
|
---|
| 59 |
|
---|
| 60 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
---|
| 61 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
---|
| 62 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
---|
| 63 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
---|
| 64 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
---|
| 65 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
---|
| 66 | DEALINGS IN THE SOFTWARE.
|
---|
| 67 |
|
---|