Skip to content

Commit f0472f2

Browse files
committed
[Feature #21785] [DOC] LEB128 support
1 parent 7b19f1a commit f0472f2

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

doc/language/packed_data.rdoc

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,22 @@ for one element in the input or output array.
342342
s.unpack('U*')
343343
# => [4194304]
344344

345+
- <tt>'r'</tt> - Signed LEB128-encoded integer
346+
(see {Signed LEB128}[https://en.wikipedia.org/wiki/LEB128#Signed_LEB128])
347+
348+
s = [1, 127, -128, 16383, -16384].pack("r*")
349+
# => "\x01\xFF\x00\x80\x7F\xFF\xFF\x00\x80\x80\x7F"
350+
s.unpack('r*')
351+
# => [1, 127, -128, 16383, -16384]
352+
353+
- <tt>'R'</tt> - Unsigned LEB128-encoded integer
354+
(see {Unsigned LEB128}[https://en.wikipedia.org/wiki/LEB128#Unsigned_LEB128])
355+
356+
s = [1, 127, 128, 16383, 16384].pack("R*")
357+
# => "\x01\x7F\x80\x01\xFF\x7F\x80\x80\x01"
358+
s.unpack('R*')
359+
# => [1, 127, 128, 16383, 16384]
360+
345361
- <tt>'w'</tt> - BER-encoded integer
346362
(see {BER encoding}[https://en.wikipedia.org/wiki/X.690#BER_encoding]):
347363

0 commit comments

Comments
 (0)