diff options
| author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2025-12-19 17:16:15 +0900 |
|---|---|---|
| committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2025-12-19 17:16:15 +0900 |
| commit | f0472f2d49c896bf072d327ff2a4ee009115266f (patch) | |
| tree | cbb408bdea5456370604104a8cf7227f2883e683 /doc | |
| parent | 7b19f1a1ef4c66a8a8f8fb64cb08ecca2044884c (diff) | |
[Feature #21785] [DOC] LEB128 support
Diffstat (limited to 'doc')
| -rw-r--r-- | doc/language/packed_data.rdoc | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/doc/language/packed_data.rdoc b/doc/language/packed_data.rdoc index dcb4d55735..97079f7f08 100644 --- a/doc/language/packed_data.rdoc +++ b/doc/language/packed_data.rdoc @@ -342,6 +342,22 @@ for one element in the input or output array. s.unpack('U*') # => [4194304] +- <tt>'r'</tt> - Signed LEB128-encoded integer + (see {Signed LEB128}[https://en.wikipedia.org/wiki/LEB128#Signed_LEB128]) + + s = [1, 127, -128, 16383, -16384].pack("r*") + # => "\x01\xFF\x00\x80\x7F\xFF\xFF\x00\x80\x80\x7F" + s.unpack('r*') + # => [1, 127, -128, 16383, -16384] + +- <tt>'R'</tt> - Unsigned LEB128-encoded integer + (see {Unsigned LEB128}[https://en.wikipedia.org/wiki/LEB128#Unsigned_LEB128]) + + s = [1, 127, 128, 16383, 16384].pack("R*") + # => "\x01\x7F\x80\x01\xFF\x7F\x80\x80\x01" + s.unpack('R*') + # => [1, 127, 128, 16383, 16384] + - <tt>'w'</tt> - BER-encoded integer (see {BER encoding}[https://en.wikipedia.org/wiki/X.690#BER_encoding]): |
