From f0472f2d49c896bf072d327ff2a4ee009115266f Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Fri, 19 Dec 2025 17:16:15 +0900 Subject: [PATCH] [Feature #21785] [DOC] LEB128 support --- doc/language/packed_data.rdoc | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) 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] +- 'r' - 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] + +- 'R' - 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] + - 'w' - BER-encoded integer (see {BER encoding}[https://en.wikipedia.org/wiki/X.690#BER_encoding]):