[DOC] table format refined.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56488 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2016-10-25 03:48:23 +00:00
parent f785ac9f38
commit 58206933b4

322
pack.c
View File

@ -174,100 +174,94 @@ rb_str_associated(VALUE str)
* *
* Directives for +pack+. * Directives for +pack+.
* *
* Integer | Array | * Integer | Array |
* Directive | Element | Meaning
* ----------------------------------------------------------------------------
* C | Integer | 8-bit unsigned (unsigned char)
* S | Integer | 16-bit unsigned, native endian (uint16_t)
* L | Integer | 32-bit unsigned, native endian (uint32_t)
* Q | Integer | 64-bit unsigned, native endian (uint64_t)
* J | Integer | pointer width unsigned, native endian (uintptr_t)
* | | (J is available since Ruby 2.3.)
* | |
* c | Integer | 8-bit signed (signed char)
* s | Integer | 16-bit signed, native endian (int16_t)
* l | Integer | 32-bit signed, native endian (int32_t)
* q | Integer | 64-bit signed, native endian (int64_t)
* j | Integer | pointer width signed, native endian (intptr_t)
* | | (j is available since Ruby 2.3.)
* | |
* S_ S! | Integer | unsigned short, native endian
* I I_ I! | Integer | unsigned int, native endian
* L_ L! | Integer | unsigned long, native endian
* Q_ Q! | Integer | unsigned long long, native endian (ArgumentError
* | | if the platform has no long long type.)
* | | (Q_ and Q! is available since Ruby 2.1.)
* J! | Integer | uintptr_t, native endian (same with J)
* | | (J! is available since Ruby 2.3.)
* | |
* s_ s! | Integer | signed short, native endian
* i i_ i! | Integer | signed int, native endian
* l_ l! | Integer | signed long, native endian
* q_ q! | Integer | signed long long, native endian (ArgumentError
* | | if the platform has no long long type.)
* | | (q_ and q! is available since Ruby 2.1.)
* j! | Integer | intptr_t, native endian (same with j)
* | | (j! is available since Ruby 2.3.)
* | |
* S> s> S!> s!> | Integer | same as the directives without ">" except
* L> l> L!> l!> | | big endian
* I!> i!> | | (available since Ruby 1.9.3)
* Q> q> Q!> q!> | | "S>" is same as "n"
* J> j> J!> j!> | | "L>" is same as "N"
* | |
* S< s< S!< s!< | Integer | same as the directives without "<" except
* L< l< L!< l!< | | little endian
* I!< i!< | | (available since Ruby 1.9.3)
* Q< q< Q!< q!< | | "S<" is same as "v"
* J< j< J!< j!< | | "L<" is same as "V"
* | |
* n | Integer | 16-bit unsigned, network (big-endian) byte order
* N | Integer | 32-bit unsigned, network (big-endian) byte order
* v | Integer | 16-bit unsigned, VAX (little-endian) byte order
* V | Integer | 32-bit unsigned, VAX (little-endian) byte order
* | |
* U | Integer | UTF-8 character
* w | Integer | BER-compressed integer
*
* Float | Array |
* Directive | Element | Meaning * Directive | Element | Meaning
* --------------------------------------------------------------------------- * ---------------------------------------------------------------------------
* C | Integer | 8-bit unsigned (unsigned char) * D d | Float | double-precision, native format
* S | Integer | 16-bit unsigned, native endian (uint16_t) * F f | Float | single-precision, native format
* L | Integer | 32-bit unsigned, native endian (uint32_t) * E | Float | double-precision, little-endian byte order
* Q | Integer | 64-bit unsigned, native endian (uint64_t) * e | Float | single-precision, little-endian byte order
* J | Integer | pointer width unsigned, native endian (uintptr_t) * G | Float | double-precision, network (big-endian) byte order
* | | (J is available since Ruby 2.3.) * g | Float | single-precision, network (big-endian) byte order
* | |
* c | Integer | 8-bit signed (signed char)
* s | Integer | 16-bit signed, native endian (int16_t)
* l | Integer | 32-bit signed, native endian (int32_t)
* q | Integer | 64-bit signed, native endian (int64_t)
* j | Integer | pointer width signed, native endian (intptr_t)
* | | (j is available since Ruby 2.3.)
* | |
* S_, S! | Integer | unsigned short, native endian
* I, I_, I! | Integer | unsigned int, native endian
* L_, L! | Integer | unsigned long, native endian
* Q_, Q! | Integer | unsigned long long, native endian (ArgumentError
* | | if the platform has no long long type.)
* | | (Q_ and Q! is available since Ruby 2.1.)
* J! | Integer | uintptr_t, native endian (same with J)
* | | (J! is available since Ruby 2.3.)
* | |
* s_, s! | Integer | signed short, native endian
* i, i_, i! | Integer | signed int, native endian
* l_, l! | Integer | signed long, native endian
* q_, q! | Integer | signed long long, native endian (ArgumentError
* | | if the platform has no long long type.)
* | | (q_ and q! is available since Ruby 2.1.)
* j! | Integer | intptr_t, native endian (same with j)
* | | (j! is available since Ruby 2.3.)
* | |
* S> L> Q> | Integer | same as the directives without ">" except
* J> s> l> | | big endian
* q> j> | | (available since Ruby 1.9.3)
* S!> I!> | | "S>" is same as "n"
* L!> Q!> | | "L>" is same as "N"
* J!> s!> | |
* i!> l!> | |
* q!> j!> | |
* | |
* S< L< Q< | Integer | same as the directives without "<" except
* J< s< l< | | little endian
* q< j< | | (available since Ruby 1.9.3)
* S!< I!< | | "S<" is same as "v"
* L!< Q!< | | "L<" is same as "V"
* J!< s!< | |
* i!< l!< | |
* q!< j!< | |
* | |
* n | Integer | 16-bit unsigned, network (big-endian) byte order
* N | Integer | 32-bit unsigned, network (big-endian) byte order
* v | Integer | 16-bit unsigned, VAX (little-endian) byte order
* V | Integer | 32-bit unsigned, VAX (little-endian) byte order
* | |
* U | Integer | UTF-8 character
* w | Integer | BER-compressed integer
* *
* Float | | * String | Array |
* Directive | | Meaning * Directive | Element | Meaning
* --------------------------------------------------------------------------- * ---------------------------------------------------------------------------
* D, d | Float | double-precision, native format * A | String | arbitrary binary string (space padded, count is width)
* F, f | Float | single-precision, native format * a | String | arbitrary binary string (null padded, count is width)
* E | Float | double-precision, little-endian byte order * Z | String | same as ``a'', except that null is added with *
* e | Float | single-precision, little-endian byte order * B | String | bit string (MSB first)
* G | Float | double-precision, network (big-endian) byte order * b | String | bit string (LSB first)
* g | Float | single-precision, network (big-endian) byte order * H | String | hex string (high nibble first)
* * h | String | hex string (low nibble first)
* String | | * u | String | UU-encoded string
* Directive | | Meaning * M | String | quoted printable, MIME encoding (see RFC2045)
* --------------------------------------------------------------------------- * m | String | base64 encoded string (see RFC 2045, count is width)
* A | String | arbitrary binary string (space padded, count is width)
* a | String | arbitrary binary string (null padded, count is width)
* Z | String | same as ``a'', except that null is added with *
* B | String | bit string (MSB first)
* b | String | bit string (LSB first)
* H | String | hex string (high nibble first)
* h | String | hex string (low nibble first)
* u | String | UU-encoded string
* M | String | quoted printable, MIME encoding (see RFC2045)
* m | String | base64 encoded string (see RFC 2045, count is width)
* | | (if count is 0, no line feed are added, see RFC 4648) * | | (if count is 0, no line feed are added, see RFC 4648)
* P | String | pointer to a structure (fixed-length string) * P | String | pointer to a structure (fixed-length string)
* p | String | pointer to a null-terminated string * p | String | pointer to a null-terminated string
* *
* Misc. | | * Misc. | Array |
* Directive | | Meaning * Directive | Element | Meaning
* --------------------------------------------------------------------------- * ---------------------------------------------------------------------------
* @ | --- | moves to absolute position * @ | --- | moves to absolute position
* X | --- | back up a byte * X | --- | back up a byte
* x | --- | null byte * x | --- | null byte
*/ */
static VALUE static VALUE
@ -1059,98 +1053,94 @@ infected_str_new(const char *ptr, long len, VALUE str)
* This table summarizes the various formats and the Ruby classes * This table summarizes the various formats and the Ruby classes
* returned by each. * returned by each.
* *
* Integer | | * Integer | |
* Directive | Returns | Meaning * Directive | Returns | Meaning
* ----------------------------------------------------------------- * ------------------------------------------------------------------
* C | Integer | 8-bit unsigned (unsigned char) * C | Integer | 8-bit unsigned (unsigned char)
* S | Integer | 16-bit unsigned, native endian (uint16_t) * S | Integer | 16-bit unsigned, native endian (uint16_t)
* L | Integer | 32-bit unsigned, native endian (uint32_t) * L | Integer | 32-bit unsigned, native endian (uint32_t)
* Q | Integer | 64-bit unsigned, native endian (uint64_t) * Q | Integer | 64-bit unsigned, native endian (uint64_t)
* J | Integer | pointer width unsigned, native endian (uintptr_t) * J | Integer | pointer width unsigned, native endian (uintptr_t)
* | | (J is available since Ruby 2.3.) * | | (J is available since Ruby 2.3.)
* | | * | |
* c | Integer | 8-bit signed (signed char) * c | Integer | 8-bit signed (signed char)
* s | Integer | 16-bit signed, native endian (int16_t) * s | Integer | 16-bit signed, native endian (int16_t)
* l | Integer | 32-bit signed, native endian (int32_t) * l | Integer | 32-bit signed, native endian (int32_t)
* q | Integer | 64-bit signed, native endian (int64_t) * q | Integer | 64-bit signed, native endian (int64_t)
* j | Integer | pointer width signed, native endian (intptr_t) * j | Integer | pointer width signed, native endian (intptr_t)
* | | (j is available since Ruby 2.3.) * | | (j is available since Ruby 2.3.)
* | | * | |
* S_, S! | Integer | unsigned short, native endian * S_ S! | Integer | unsigned short, native endian
* I, I_, I! | Integer | unsigned int, native endian * I I_ I! | Integer | unsigned int, native endian
* L_, L! | Integer | unsigned long, native endian * L_ L! | Integer | unsigned long, native endian
* Q_, Q! | Integer | unsigned long long, native endian (ArgumentError * Q_ Q! | Integer | unsigned long long, native endian (ArgumentError
* | | if the platform has no long long type.) * | | if the platform has no long long type.)
* | | (Q_ and Q! is available since Ruby 2.1.) * | | (Q_ and Q! is available since Ruby 2.1.)
* J! | Integer | uintptr_t, native endian (same with J) * J! | Integer | uintptr_t, native endian (same with J)
* | | (J! is available since Ruby 2.3.) * | | (J! is available since Ruby 2.3.)
* | | * | |
* s_, s! | Integer | signed short, native endian * s_ s! | Integer | signed short, native endian
* i, i_, i! | Integer | signed int, native endian * i i_ i! | Integer | signed int, native endian
* l_, l! | Integer | signed long, native endian * l_ l! | Integer | signed long, native endian
* q_, q! | Integer | signed long long, native endian (ArgumentError * q_ q! | Integer | signed long long, native endian (ArgumentError
* | | if the platform has no long long type.) * | | if the platform has no long long type.)
* | | (q_ and q! is available since Ruby 2.1.) * | | (q_ and q! is available since Ruby 2.1.)
* j! | Integer | intptr_t, native endian (same with j) * j! | Integer | intptr_t, native endian (same with j)
* | | (j! is available since Ruby 2.3.) * | | (j! is available since Ruby 2.3.)
* | | * | |
* S> L> Q> | Integer | same as the directives without ">" except * S> s> S!> s!> | Integer | same as the directives without ">" except
* s> l> q> | | big endian * L> l> L!> l!> | | big endian
* S!> I!> | | (available since Ruby 1.9.3) * I!> i!> | | (available since Ruby 1.9.3)
* L!> Q!> | | "S>" is same as "n" * Q> q> Q!> q!> | | "S>" is same as "n"
* s!> i!> | | "L>" is same as "N" * J> j> J!> j!> | | "L>" is same as "N"
* l!> q!> | | * | |
* J> j> J!> j!>| | * S< s< S!< s!< | Integer | same as the directives without "<" except
* | | * L< l< L!< l!< | | little endian
* S< L< Q< | Integer | same as the directives without "<" except * I!< i!< | | (available since Ruby 1.9.3)
* s< l< q< | | little endian * Q< q< Q!< q!< | | "S<" is same as "v"
* S!< I!< | | (available since Ruby 1.9.3) * J< j< J!< j!< | | "L<" is same as "V"
* L!< Q!< | | "S<" is same as "v" * | |
* s!< i!< | | "L<" is same as "V" * n | Integer | 16-bit unsigned, network (big-endian) byte order
* l!< q!< | | * N | Integer | 32-bit unsigned, network (big-endian) byte order
* J< j< J!< j!<| | * v | Integer | 16-bit unsigned, VAX (little-endian) byte order
* | | * V | Integer | 32-bit unsigned, VAX (little-endian) byte order
* n | Integer | 16-bit unsigned, network (big-endian) byte order * | |
* N | Integer | 32-bit unsigned, network (big-endian) byte order * U | Integer | UTF-8 character
* v | Integer | 16-bit unsigned, VAX (little-endian) byte order * w | Integer | BER-compressed integer (see Array.pack)
* V | Integer | 32-bit unsigned, VAX (little-endian) byte order
* | |
* U | Integer | UTF-8 character
* w | Integer | BER-compressed integer (see Array.pack)
* *
* Float | | * Float | |
* Directive | Returns | Meaning * Directive | Returns | Meaning
* ----------------------------------------------------------------- * -----------------------------------------------------------------
* D, d | Float | double-precision, native format * D d | Float | double-precision, native format
* F, f | Float | single-precision, native format * F f | Float | single-precision, native format
* E | Float | double-precision, little-endian byte order * E | Float | double-precision, little-endian byte order
* e | Float | single-precision, little-endian byte order * e | Float | single-precision, little-endian byte order
* G | Float | double-precision, network (big-endian) byte order * G | Float | double-precision, network (big-endian) byte order
* g | Float | single-precision, network (big-endian) byte order * g | Float | single-precision, network (big-endian) byte order
* *
* String | | * String | |
* Directive | Returns | Meaning * Directive | Returns | Meaning
* ----------------------------------------------------------------- * -----------------------------------------------------------------
* A | String | arbitrary binary string (remove trailing nulls and ASCII spaces) * A | String | arbitrary binary string (remove trailing nulls and ASCII spaces)
* a | String | arbitrary binary string * a | String | arbitrary binary string
* Z | String | null-terminated string * Z | String | null-terminated string
* B | String | bit string (MSB first) * B | String | bit string (MSB first)
* b | String | bit string (LSB first) * b | String | bit string (LSB first)
* H | String | hex string (high nibble first) * H | String | hex string (high nibble first)
* h | String | hex string (low nibble first) * h | String | hex string (low nibble first)
* u | String | UU-encoded string * u | String | UU-encoded string
* M | String | quoted-printable, MIME encoding (see RFC2045) * M | String | quoted-printable, MIME encoding (see RFC2045)
* m | String | base64 encoded string (RFC 2045) (default) * m | String | base64 encoded string (RFC 2045) (default)
* | | base64 encoded string (RFC 4648) if followed by 0 * | | base64 encoded string (RFC 4648) if followed by 0
* P | String | pointer to a structure (fixed-length string) * P | String | pointer to a structure (fixed-length string)
* p | String | pointer to a null-terminated string * p | String | pointer to a null-terminated string
* *
* Misc. | | * Misc. | |
* Directive | Returns | Meaning * Directive | Returns | Meaning
* ----------------------------------------------------------------- * -----------------------------------------------------------------
* @ | --- | skip to the offset given by the length argument * @ | --- | skip to the offset given by the length argument
* X | --- | skip backward one byte * X | --- | skip backward one byte
* x | --- | skip forward one byte * x | --- | skip forward one byte
*/ */
static VALUE static VALUE