ÿØÿà JFIF    ÿÛ „  ( %!1!%)+//.383,7(-.+  -%%-////---/-.+/--+------/------/--0+--/-/-----.-----ÿÀ  ¥2" ÿÄ     ÿÄ J    ! 1AQ"aq2‘#BR‚¡ÁÑ3br’¢±Âð$CSƒ²á4c“%DsÓñÿÄ   ÿÄ *  !1AQa‘"2q3±ð#b¡ÿÚ   ? ¼QxJQaÍuò¸Zö Úü8,ÐÚú "SSn<rçù–´âE—^ªBÖ9À\†¸ÔÁT­ÃÛ5 ëd´³Í#Ý;Þ38œî ¶H£M:wÎ3…³…âpÔF&‚FK¸9„â4àGEõªfÿ ‘ñ(ßw­pŽF|È¥ù®häðÍѶ¹‘[ÒinÙW¶ùñY˜Q{›K"išÒ[Ú8žë\F¹@-?v"ÔU”,ìöžkÿ {I‡£šÍ?e ríV ?> ......................................... ............................................................................. ÿØÿà JFIF    ÿÛ „  ( %!1!%)+//.383,7(-.+  -%%-////---/-.+/--+------/------/--0+--/-/-----.-----ÿÀ  ¥2" ÿÄ     ÿÄ J    ! 1AQ"aq2‘#BR‚¡ÁÑ3br’¢±Âð$CSƒ²á4c“%DsÓñÿÄ   ÿÄ *  !1AQa‘"2q3±ð#b¡ÿÚ   ? ¼QxJQaÍuò¸Zö Úü8,ÐÚú "SSn<rçù–´âE—^ªBÖ9À\†¸ÔÁT­ÃÛ5 ëd´³Í#Ý;Þ38œî ¶H£M:wÎ3…³…âpÔF&‚FK¸9„â4àGEõªfÿ ‘ñ(ßw­pŽF|È¥ù®häðÍѶ¹‘[ÒinÙW¶ùñY˜Q{›K"išÒ[Ú8žë\F¹@-?v"ÔU”,ìöžkÿ {I‡£šÍ?e ríV ?> ......................................... ............................................................................. ???????????????????????????????????? ???????????????????????????????????? ÿØÿà JFIF    ÿÛ „  ( %!1!%)+//.383,7(-.+  -%%-////---/-.+/--+------/------/--0+--/-/-----.-----ÿÀ  ¥2" ÿÄ     ÿÄ J    ! 1AQ"aq2‘#BR‚¡ÁÑ3br’¢±Âð$CSƒ²á4c“%DsÓñÿÄ   ÿÄ *  !1AQa‘"2q3±ð#b¡ÿÚ   ? ¼QxJQaÍuò¸Zö Úü8,ÐÚú "SSn<rçù–´âE—^ªBÖ9À\†¸ÔÁT­ÃÛ5 ëd´³Í#Ý;Þ38œî ¶H£M:wÎ3…³…âpÔF&‚FK¸9„â4àGEõªfÿ ‘ñ(ßw­pŽF|È¥ù®häðÍѶ¹‘[ÒinÙW¶ùñY˜Q{›K"išÒ[Ú8žë\F¹@-?v"ÔU”,ìöžkÿ {I‡£šÍ?e ríV ?> ......................................... ............................................................................. ÿØÿà JFIF    ÿÛ „  ( %!1!%)+//.383,7(-.+  -%%-////---/-.+/--+------/------/--0+--/-/-----.-----ÿÀ  ¥2" ÿÄ     ÿÄ J    ! 1AQ"aq2‘#BR‚¡ÁÑ3br’¢±Âð$CSƒ²á4c“%DsÓñÿÄ   ÿÄ *  !1AQa‘"2q3±ð#b¡ÿÚ   ? ¼QxJQaÍuò¸Zö Úü8,ÐÚú "SSn<rçù–´âE—^ªBÖ9À\†¸ÔÁT­ÃÛ5 ëd´³Í#Ý;Þ38œî ¶H£M:wÎ3…³…âpÔF&‚FK¸9„â4àGEõªfÿ ‘ñ(ßw­pŽF|È¥ù®häðÍѶ¹‘[ÒinÙW¶ùñY˜Q{›K"išÒ[Ú8žë\F¹@-?v"ÔU”,ìöžkÿ {I‡£šÍ?e ríV ?> ......................................... ............................................................................. ???????????????????????????????????? ???????????????????????????????????? U:RDoc::TopLevel[ iI"packed_data.rdoc:ETcRDoc::Parser::Simpleo:RDoc::Markup::Document: @parts[~S:RDoc::Markup::Heading: leveli: textI"Packed \Data;To:RDoc::Markup::BlankLineS; ; i; I"Quick Reference;T@ o:RDoc::Markup::Paragraph;[I"EThese tables summarize the directives for packing and unpacking.;T@ S; ; i; I"For Integers;T@ o:RDoc::Markup::Verbatim;[4I"Directive | Meaning ;TI"T--------------|--------------------------------------------------------------- ;TI"4C | 8-bit unsigned (unsigned char) ;TI"?S | 16-bit unsigned, native endian (uint16_t) ;TI"?L | 32-bit unsigned, native endian (uint32_t) ;TI"?Q | 64-bit unsigned, native endian (uint64_t) ;TI"GJ | pointer width unsigned, native endian (uintptr_t) ;TI" ;TI"0c | 8-bit signed (signed char) ;TI" s> S!> s!> | each the same as the directive without >, but big endian ;TI"+L> l> L!> l!> | S> is the same as n ;TI"+I!> i!> | L> is the same as N ;TI"Q> q> Q!> q!> | ;TI"J> j> J!> j!> | ;TI" ;TI"QS< s< S!< s!< | each the same as the directive without <, but little endian ;TI"+L< l< L!< l!< | S< is the same as v ;TI"+I!< i!< | L< is the same as V ;TI"Q< q< Q!< q!< | ;TI"J< j< J!< j!< | ;TI" ;TI"Fn | 16-bit unsigned, network (big-endian) byte order ;TI"FN | 32-bit unsigned, network (big-endian) byte order ;TI"Ev | 16-bit unsigned, VAX (little-endian) byte order ;TI"EV | 32-bit unsigned, VAX (little-endian) byte order ;TI" ;TI"%U | UTF-8 character ;TI",w | BER-compressed integer ;T: @format0S; ; i; I"For Floats;T@ o;;[ I"Directive | Meaning ;TI"C----------|-------------------------------------------------- ;TI"1D d | double-precision, native format ;TI"1F f | single-precision, native format ;TI"P | pointer to a structure (fixed-length string) ;TI"5p | pointer to a null-terminated string ;T;0S; ; i; I"&Additional Directives for Packing;T@ o;;[ I"Directive | Meaning ;TI"Q----------|---------------------------------------------------------------- ;TI",@ | moves to absolute position ;TI" X | back up a byte ;TI"x | null byte ;T;0S; ; i; I"(Additional Directives for Unpacking;T@ o;;[ I"Directive | Meaning ;TI"Q----------|---------------------------------------------------------------- ;TI"A@ | skip to the offset given by the length argument ;TI"(X | skip backward one byte ;TI"'x | skip forward one byte ;T;0S; ; i; I"Packing and Unpacking;T@ o; ;[I"DCertain Ruby core methods deal with packing and unpacking data:;T@ o:RDoc::Markup::List: @type: BULLET: @items[o:RDoc::Markup::ListItem: @label0;[o; ;[I"\Method Array#pack: ;TI"@Formats each element in array +self+ into a binary string; ;TI"returns that string.;To;;0;[o; ;[ I"\Method String#unpack: ;TI"'Extracts data from string +self+, ;TI">forming objects that become the elements of a new array; ;TI"returns that array.;To;;0;[o; ;[I"\Method String#unpack1: ;TI"LDoes the same, but unpacks and returns only the first extracted object.;T@ o; ;[I"8Each of these methods accepts a string +template+, ;TI"8consisting of zero or more _directive_ characters, ;TI"9each followed by zero or more _modifier_ characters.;T@ o; ;[I"FExamples (directive 'C' specifies 'unsigned character'):;T@ o;;[I"A[65].pack('C') # => "A" # One element, one directive. ;TI"C[65, 66].pack('CC') # => "AB" # Two elements, two directives. ;TI"?[65, 66].pack('C') # => "A" # Extra element is ignored. ;TI"4[65].pack('') # => "" # No directives. ;TI"K[65].pack('CC') # Extra directive raises ArgumentError. ;TI" ;TI"F'A'.unpack('C') # => [65] # One character, one directive. ;TI"H'AB'.unpack('CC') # => [65, 66] # Two characters, two directives. ;TI"D'AB'.unpack('C') # => [65] # Extra character is ignored. ;TI"G'A'.unpack('CC') # => [65, nil] # Extra directive generates nil. ;TI"7'AB'.unpack('') # => [] # No directives. ;T;0o; ;[I"GThe string +template+ may contain any mixture of valid directives ;TI";(directive 'c' specifies 'signed character'):;T@ o;;[I"'[65, -1].pack('cC') # => "A\xFF" ;TI")"A\xFF".unpack('cC') # => [65, 255] ;T;0o; ;[I"EThe string +template+ may contain whitespace (which is ignored) ;TI"Dand comments, each of which begins with character '#' ;TI"Band continues up to and including the next following newline:;T@ o;;[I"8[0,1].pack(" C #foo \n C ") # => "\x00\x01" ;TI"4"\0\1".unpack(" C #foo \n C ") # => [0, 1] ;T;0o; ;[I"@Any directive may be followed by either of these modifiers:;T@ o;;;;[o;;0;[o; ;[I"K'*' - The directive is to be applied as many times as needed:;T@ o;;[I"#[65, 66].pack('C*') # => "AB" ;TI"''AB'.unpack('C*') # => [65, 66] ;T;0o;;0;[ o; ;[I"DInteger +count+ - The directive is to be applied +count+ times:;T@ o;;[ I"#[65, 66].pack('C2') # => "AB" ;TI"1[65, 66].pack('C3') # Raises ArgumentError. ;TI"''AB'.unpack('C2') # => [65, 66] ;TI",'AB'.unpack('C3') # => [65, 66, nil] ;T;0o; ;[I"GNote: Directives in %w[A a Z m] use +count+ differently; ;TI"Jsee {String Directives}[rdoc-ref:packed_data.rdoc@String+Directives].;T@ o; ;[I"[If elements don't fit the provided directive, only least significant bits are encoded:;T@ o;;[I"*[257].pack("C").unpack("C") # => [1] ;T;0S; ; i; I"Packing \Method;T@ o; ;[I":\Method Array#pack accepts optional keyword argument ;TI"I+buffer+ that specifies the target string (instead of a new string):;T@ o;;[I"5[65, 66].pack('C*', buffer: 'foo') # => "fooAB" ;T;0o; ;[I"#The method can accept a block:;T@ o;;[I"-# Packed string is passed to the block. ;TI"1[65, 66].pack('C*') {|s| p s } # => "AB" ;T;0S; ; i; I"Unpacking Methods;T@ o; ;[I":Methods String#unpack and String#unpack1 each accept ;TI"Dan optional keyword argument +offset+ that specifies an offset ;TI"into the string:;T@ o;;[I"2'ABC'.unpack('C*', offset: 1) # => [66, 67] ;TI",'ABC'.unpack1('C*', offset: 1) # => 66 ;T;0o; ;[I"%Both methods can accept a block:;T@ o;;[ I"4# Each unpacked object is passed to the block. ;TI"ret = [] ;TI")"ABCD".unpack("C*") {|c| ret << c } ;TI"ret # => [65, 66, 67, 68] ;TI" ;TI":# The single unpacked object is passed to the block. ;TI"/'AB'.unpack1('C*') {|ele| p ele } # => 65 ;T;0S; ; i; I"\Integer Directives;T@ o; ;[I"?Each integer directive specifies the packing or unpacking ;TI"2for one element in the input or output array.;T@ S; ; i; I"8-Bit \Integer Directives;T@ o;;;;[o;;0;[o; ;[I")'c' - 8-bit signed integer ;TI"#(like C signed char):;T@ o;;[I"1[0, 1, 255].pack('c*') # => "\x00\x01\xFF" ;TI"3s = [0, 1, -1].pack('c*') # => "\x00\x01\xFF" ;TI"$s.unpack('c*') # => [0, 1, -1] ;T;0o;;0;[o; ;[I"+'C' - 8-bit unsigned integer ;TI"%(like C unsigned char):;T@ o;;[I"3[0, 1, 255].pack('C*') # => "\x00\x01\xFF" ;TI"3s = [0, 1, -1].pack('C*') # => "\x00\x01\xFF" ;TI"0s.unpack('C*') # => [0, 1, 255] ;T;0S; ; i; I"16-Bit \Integer Directives;T@ o;;;;[ o;;0;[o; ;[I"9's' - 16-bit signed integer, native-endian ;TI"(like C int16_t):;T@ o;;[I"9[513, -514].pack('s*') # => "\x01\x02\xFE\xFD" ;TI"9s = [513, 65022].pack('s*') # => "\x01\x02\xFE\xFD" ;TI"2s.unpack('s*') # => [513, -514] ;T;0o;;0;[o; ;[I";'S' - 16-bit unsigned integer, native-endian ;TI" (like C uint16_t):;T@ o;;[I"9[513, -514].pack('S*') # => "\x01\x02\xFE\xFD" ;TI"9s = [513, 65022].pack('S*') # => "\x01\x02\xFE\xFD" ;TI"3s.unpack('S*') # => [513, 65022] ;T;0o;;0;[o; ;[I"7'n' - 16-bit network integer, big-endian:;T@ o;;[ I"5s = [0, 1, -1, 32767, -32768, 65535].pack('n*') ;TI"=# => "\x00\x00\x00\x01\xFF\xFF\x7F\xFF\x80\x00\xFF\xFF" ;TI"s.unpack('n*') ;TI"-# => [0, 1, 65535, 32767, 32768, 65535] ;T;0o;;0;[o; ;[I"6'v' - 16-bit VAX integer, little-endian:;T@ o;;[ I"5s = [0, 1, -1, 32767, -32768, 65535].pack('v*') ;TI"=# => "\x00\x00\x01\x00\xFF\xFF\xFF\x7F\x00\x80\xFF\xFF" ;TI"s.unpack('v*') ;TI"-# => [0, 1, 65535, 32767, 32768, 65535] ;T;0S; ; i; I"32-Bit \Integer Directives;T@ o;;;;[ o;;0;[o; ;[I"9'l' - 32-bit signed integer, native-endian ;TI"(like C int32_t):;T@ o;;[ I"*s = [67305985, -50462977].pack('l*') ;TI"-# => "\x01\x02\x03\x04\xFF\xFE\xFD\xFC" ;TI"s.unpack('l*') ;TI" # => [67305985, -50462977] ;T;0o;;0;[o; ;[I";'L' - 32-bit unsigned integer, native-endian ;TI" (like C uint32_t):;T@ o;;[ I"+s = [67305985, 4244504319].pack('L*') ;TI"-# => "\x01\x02\x03\x04\xFF\xFE\xFD\xFC" ;TI"s.unpack('L*') ;TI"!# => [67305985, 4244504319] ;T;0o;;0;[o; ;[I"7'N' - 32-bit network integer, big-endian:;T@ o;;[ I"s = [0,1,-1].pack('N*') ;TI"=# => "\x00\x00\x00\x00\x00\x00\x00\x01\xFF\xFF\xFF\xFF" ;TI"s.unpack('N*') ;TI"# => [0, 1, 4294967295] ;T;0o;;0;[o; ;[I"6'V' - 32-bit VAX integer, little-endian:;T@ o;;[ I"s = [0,1,-1].pack('V*') ;TI"=# => "\x00\x00\x00\x00\x01\x00\x00\x00\xFF\xFF\xFF\xFF" ;TI"s.unpack('v*') ;TI"%# => [0, 0, 1, 0, 65535, 65535] ;T;0S; ; i; I"64-Bit \Integer Directives;T@ o;;;;[o;;0;[o; ;[I"9'q' - 64-bit signed integer, native-endian ;TI"(like C int64_t):;T@ o;;[ I">s = [578437695752307201, -506097522914230529].pack('q*') ;TI"I# => "\x01\x02\x03\x04\x05\x06\a\b\xFF\xFE\xFD\xFC\xFB\xFA\xF9\xF8" ;TI"s.unpack('q*') ;TI"4# => [578437695752307201, -506097522914230529] ;T;0o;;0;[o; ;[I";'Q' - 64-bit unsigned integer, native-endian ;TI" (like C uint64_t):;T@ o;;[ I"?s = [578437695752307201, 17940646550795321087].pack('Q*') ;TI"I# => "\x01\x02\x03\x04\x05\x06\a\b\xFF\xFE\xFD\xFC\xFB\xFA\xF9\xF8" ;TI"s.unpack('Q*') ;TI"5# => [578437695752307201, 17940646550795321087] ;T;0S; ; i; I"+Platform-Dependent \Integer Directives;T@ o;;;;[ o;;0;[o; ;[I"='i' - Platform-dependent width signed integer, ;TI")native-endian (like C int):;T@ o;;[ I"*s = [67305985, -50462977].pack('i*') ;TI"-# => "\x01\x02\x03\x04\xFF\xFE\xFD\xFC" ;TI"s.unpack('i*') ;TI" # => [67305985, -50462977] ;T;0o;;0;[o; ;[I"?'I' - Platform-dependent width unsigned integer, ;TI"2native-endian (like C unsigned int):;T@ o;;[ I"*s = [67305985, -50462977].pack('I*') ;TI"-# => "\x01\x02\x03\x04\xFF\xFE\xFD\xFC" ;TI"s.unpack('I*') ;TI"!# => [67305985, 4244504319] ;T;0o;;0;[o; ;[I"@'j' - Pointer-width signed integer, native-endian ;TI" (like C intptr_t):;T@ o;;[ I"*s = [67305985, -50462977].pack('j*') ;TI"M# => "\x01\x02\x03\x04\x00\x00\x00\x00\xFF\xFE\xFD\xFC\xFF\xFF\xFF\xFF" ;TI"s.unpack('j*') ;TI" # => [67305985, -50462977] ;T;0o;;0;[o; ;[I"B'J' - Pointer-width unsigned integer, native-endian ;TI"!(like C uintptr_t):;T@ o;;[ I"+s = [67305985, 4244504319].pack('J*') ;TI"M# => "\x01\x02\x03\x04\x00\x00\x00\x00\xFF\xFE\xFD\xFC\x00\x00\x00\x00" ;TI"s.unpack('J*') ;TI"!# => [67305985, 4244504319] ;T;0S; ; i; I"Other \Integer Directives;T@ o;;;;[o;;0;[o; ;[I"$'U' - UTF-8 character:;T@ o;;[ I"s = [4194304].pack('U*') ;TI"!# => "\xF8\x90\x80\x80\x80" ;TI"s.unpack('U*') ;TI"# => [4194304] ;T;0o;;0;[o; ;[I"('w' - BER-encoded integer ;TI"L(see {BER encoding}[https://en.wikipedia.org/wiki/X.690#BER_encoding]):;T@ o;;[ I"!s = [1073741823].pack('w*') ;TI"!# => "\x83\xFF\xFF\xFF\x7F" ;TI"s.unpack('w*') ;TI"# => [1073741823] ;T;0S; ; i; I"&Modifiers for \Integer Directives;T@ o; ;[I"QFor the following directives, '!' or '_' modifiers may be ;TI"5suffixed as underlying platform’s native size.;T@ o;;;;[ o;;0;[o; ;[I"E'i', 'I' - C int, always native size.;To;;0;[o; ;[I"3's', 'S' - C short.;To;;0;[o; ;[I"2'l', 'L' - C long.;To;;0;[o; ;[I"E'q', 'Q' - C long long, if available.;To;;0;[o; ;[I"J'j', 'J' - C intptr_t, always native size.;T@ o; ;[I"RNative size modifiers are silently ignored for always native size directives.;T@ o; ;[I"GThe endian modifiers also may be suffixed in the directives above:;T@ o;;;;[o;;0;[o; ;[I"'>' - Big-endian.;To;;0;[o; ;[I""'<' - Little-endian.;T@ S; ; i; I"\Float Directives;T@ o; ;[I"=Each float directive specifies the packing or unpacking ;TI"2for one element in the input or output array.;T@ S; ; i; I"'Single-Precision \Float Directives;T@ o;;;;[o;;0;[o; ;[I"2'F' or 'f' - Native format:;T@ o;;[I"+s = [3.0].pack('F') # => "\x00\x00@@" ;TI"$s.unpack('F') # => [3.0] ;T;0o;;0;[o; ;[I""'e' - Little-endian:;T@ o;;[I"+s = [3.0].pack('e') # => "\x00\x00@@" ;TI"$s.unpack('e') # => [3.0] ;T;0o;;0;[o; ;[I"'g' - Big-endian:;T@ o;;[I"+s = [3.0].pack('g') # => "@@\x00\x00" ;TI"$s.unpack('g') # => [3.0] ;T;0S; ; i; I"'Double-Precision \Float Directives;T@ o;;;;[o;;0;[o; ;[I"2'D' or 'd' - Native format:;T@ o;;[I" "\x00\x00\x00\x00\x00\x00\b@" ;TI"$s.unpack('D') # => [3.0] ;T;0o;;0;[o; ;[I""'E' - Little-endian:;T@ o;;[I" "\x00\x00\x00\x00\x00\x00\b@" ;TI"$s.unpack('E') # => [3.0] ;T;0o;;0;[o; ;[I"'G' - Big-endian:;T@ o;;[I" "@\b\x00\x00\x00\x00\x00\x00" ;TI"$s.unpack('G') # => [3.0] ;T;0o; ;[I"7A float directive may be infinity or not-a-number:;T@ o;;[ I"2inf = 1.0/0.0 # => Infinity ;TI"<[inf].pack('f') # => "\x00\x00\x80\x7F" ;TI"4"\x00\x00\x80\x7F".unpack('f') # => [Infinity] ;TI" ;TI"-nan = inf/inf # => NaN ;TI"<[nan].pack('f') # => "\x00\x00\xC0\x7F" ;TI"/"\x00\x00\xC0\x7F".unpack('f') # => [NaN] ;T;0S; ; i; I"\String Directives;T@ o; ;[I">Each string directive specifies the packing or unpacking ;TI"0for one byte in the input or output string.;T@ S; ; i; I"Binary \String Directives;T@ o;;;;[o;;0;[o; ;[I"L'A' - Arbitrary binary string (space padded; count is width); ;TI"*+nil+ is treated as the empty string:;T@ o;;[I"#['foo'].pack('A') # => "f" ;TI"%['foo'].pack('A*') # => "foo" ;TI"$['foo'].pack('A2') # => "fo" ;TI"&['foo'].pack('A4') # => "foo " ;TI"#[nil].pack('A') # => " " ;TI""[nil].pack('A*') # => "" ;TI"$[nil].pack('A2') # => " " ;TI"&[nil].pack('A4') # => " " ;TI" ;TI")"foo\0".unpack('A') # => ["f"] ;TI"+"foo\0".unpack('A4') # => ["foo"] ;TI"E"foo\0bar".unpack('A10') # => ["foo\x00bar"] # Reads past "\0". ;TI")"foo ".unpack('A') # => ["f"] ;TI"+"foo ".unpack('A4') # => ["foo"] ;TI"+"foo".unpack('A4') # => ["foo"] ;TI" ;TI"5russian = "\u{442 435 441 442}" # => "тест" ;TI"!russian.size # => 4 ;TI"!russian.bytesize # => 8 ;TI"&[russian].pack('A') # => "\xD1" ;TI"B[russian].pack('A*') # => "\xD1\x82\xD0\xB5\xD1\x81\xD1\x82" ;TI"(russian.unpack('A') # => ["\xD1"] ;TI",russian.unpack('A2') # => ["\xD1\x82"] ;TI"4russian.unpack('A4') # => ["\xD1\x82\xD0\xB5"] ;TI"Drussian.unpack('A*') # => ["\xD1\x82\xD0\xB5\xD1\x81\xD1\x82"] ;T;0o;;0;[o; ;[I"J'a' - Arbitrary binary string (null padded; count is width):;T@ o;;[I"#["foo"].pack('a') # => "f" ;TI"%["foo"].pack('a*') # => "foo" ;TI"$["foo"].pack('a2') # => "fo" ;TI")["foo\0"].pack('a4') # => "foo\x00" ;TI"&[nil].pack('a') # => "\x00" ;TI""[nil].pack('a*') # => "" ;TI"*[nil].pack('a2') # => "\x00\x00" ;TI"2[nil].pack('a4') # => "\x00\x00\x00\x00" ;TI" ;TI"("foo\0".unpack('a') # => ["f"] ;TI"."foo\0".unpack('a4') # => ["foo\x00"] ;TI"+"foo ".unpack('a4') # => ["foo "] ;TI"*"foo".unpack('a4') # => ["foo"] ;TI"A"foo\0bar".unpack('a4') # => ["foo\x00"] # Reads past "\0". ;T;0o;;0;[o; ;[I"*'Z' - Same as 'a', ;TI"'*':;T@ o;;[ I")["foo"].pack('Z*') # => "foo\x00" ;TI"&[nil].pack('Z*') # => "\x00" ;TI" ;TI"*"foo\0".unpack('Z*') # => ["foo"] ;TI"*"foo".unpack('Z*') # => ["foo"] ;TI"E"foo\0bar".unpack('Z*') # => ["foo"] # Does not read past "\0". ;T;0S; ; i; I"Bit \String Directives;T@ o;;;;[o;;0;[o; ;[I"1'B' - Bit string (high byte first):;T@ o;;[I":['11111111' + '00000000'].pack('B*') # => "\xFF\x00" ;TI"7['10000000' + '01000000'].pack('B*') # => "\x80@" ;TI" ;TI"['1'].pack('B0') # => "" ;TI""['1'].pack('B1') # => "\x80" ;TI"&['1'].pack('B2') # => "\x80\x00" ;TI"&['1'].pack('B3') # => "\x80\x00" ;TI"*['1'].pack('B4') # => "\x80\x00\x00" ;TI"*['1'].pack('B5') # => "\x80\x00\x00" ;TI".['1'].pack('B6') # => "\x80\x00\x00\x00" ;TI" ;TI"7"\xff\x00".unpack("B*") # => ["1111111100000000"] ;TI"7"\x01\x02".unpack("B*") # => ["0000000100000010"] ;TI" ;TI"#"".unpack("B0") # => [""] ;TI"$"\x80".unpack("B1") # => ["1"] ;TI"%"\x80".unpack("B2") # => ["10"] ;TI"&"\x80".unpack("B3") # => ["100"] ;T;0o;;0;[o; ;[I"0'b' - Bit string (low byte first):;T@ o;;[I":['11111111' + '00000000'].pack('b*') # => "\xFF\x00" ;TI":['10000000' + '01000000'].pack('b*') # => "\x01\x02" ;TI" ;TI"['1'].pack('b0') # => "" ;TI""['1'].pack('b1') # => "\x01" ;TI"&['1'].pack('b2') # => "\x01\x00" ;TI"&['1'].pack('b3') # => "\x01\x00" ;TI"*['1'].pack('b4') # => "\x01\x00\x00" ;TI"*['1'].pack('b5') # => "\x01\x00\x00" ;TI".['1'].pack('b6') # => "\x01\x00\x00\x00" ;TI" ;TI"7"\xff\x00".unpack("b*") # => ["1111111100000000"] ;TI"7"\x01\x02".unpack("b*") # => ["1000000001000000"] ;TI" ;TI"#"".unpack("b0") # => [""] ;TI"$"\x01".unpack("b1") # => ["1"] ;TI"%"\x01".unpack("b2") # => ["10"] ;TI"&"\x01".unpack("b3") # => ["100"] ;T;0S; ; i; I"Hex \String Directives;T@ o;;;;[o;;0;[o; ;[I"3'H' - Hex string (high nibble first):;T@ o;;[I",['10ef'].pack('H*') # => "\x10\xEF" ;TI"$['10ef'].pack('H0') # => "" ;TI",['10ef'].pack('H3') # => "\x10\xE0" ;TI"0['10ef'].pack('H5') # => "\x10\xEF\x00" ;TI" ;TI"+['fff'].pack('H3') # => "\xFF\xF0" ;TI"+['fff'].pack('H4') # => "\xFF\xF0" ;TI"/['fff'].pack('H5') # => "\xFF\xF0\x00" ;TI"/['fff'].pack('H6') # => "\xFF\xF0\x00" ;TI"3['fff'].pack('H7') # => "\xFF\xF0\x00\x00" ;TI"3['fff'].pack('H8') # => "\xFF\xF0\x00\x00" ;TI" ;TI"."\x10\xef".unpack('H*') # => ["10ef"] ;TI"*"\x10\xef".unpack('H0') # => [""] ;TI"+"\x10\xef".unpack('H1') # => ["1"] ;TI","\x10\xef".unpack('H2') # => ["10"] ;TI"-"\x10\xef".unpack('H3') # => ["10e"] ;TI"."\x10\xef".unpack('H4') # => ["10ef"] ;TI"."\x10\xef".unpack('H5') # => ["10ef"] ;T;0o;;0;[o; ;[I"2'h' - Hex string (low nibble first):;T@ o;;[I")['10ef'].pack('h*') # => "\x01\xFE" ;TI"!['10ef'].pack('h0') # => "" ;TI")['10ef'].pack('h3') # => "\x01\x0E" ;TI"-['10ef'].pack('h5') # => "\x01\xFE\x00" ;TI" ;TI"(['fff'].pack('h3') # => "\xFF\x0F" ;TI"(['fff'].pack('h4') # => "\xFF\x0F" ;TI",['fff'].pack('h5') # => "\xFF\x0F\x00" ;TI",['fff'].pack('h6') # => "\xFF\x0F\x00" ;TI"0['fff'].pack('h7') # => "\xFF\x0F\x00\x00" ;TI"0['fff'].pack('h8') # => "\xFF\x0F\x00\x00" ;TI" ;TI"+"\x01\xfe".unpack('h*') # => ["10ef"] ;TI"'"\x01\xfe".unpack('h0') # => [""] ;TI"("\x01\xfe".unpack('h1') # => ["1"] ;TI")"\x01\xfe".unpack('h2') # => ["10"] ;TI"*"\x01\xfe".unpack('h3') # => ["10e"] ;TI"+"\x01\xfe".unpack('h4') # => ["10ef"] ;TI"+"\x01\xfe".unpack('h5') # => ["10ef"] ;T;0S; ; i; I"Pointer \String Directives;T@ o;;;;[o;;0;[o; ;[I"A'P' - Pointer to a structure (fixed-length string):;T@ o;;[ I"As = ['abc'].pack('P') # => "\xE0O\x7F\xE5\xA1\x01\x00\x00" ;TI")s.unpack('P*') # => ["abc"] ;TI"$".".unpack("P") # => [] ;TI"'("\0" * 8).unpack("P") # => [nil] ;TI"D[nil].pack("P") # => "\x00\x00\x00\x00\x00\x00\x00\x00" ;T;0o;;0;[o; ;[I"8'p' - Pointer to a null-terminated string:;T@ o;;[ I">s = ['abc'].pack('p') # => "(\xE4u\xE5\xA1\x01\x00\x00" ;TI")s.unpack('p*') # => ["abc"] ;TI"$".".unpack("p") # => [] ;TI"'("\0" * 8).unpack("p") # => [nil] ;TI"D[nil].pack("p") # => "\x00\x00\x00\x00\x00\x00\x00\x00" ;T;0S; ; i; I"Other \String Directives;T@ o;;;;[o;;0;[o; ;[I"5'M' - Quoted printable, MIME encoding; ;TI"5text mode, but input must use LF and output LF; ;TI"<(see {RFC 2045}[https://www.ietf.org/rfc/rfc2045.txt]):;T@ o;;[I":["a b c\td \ne"].pack('M') # => "a b c\td =\n\ne=\n" ;TI".["\0"].pack('M') # => "=00=\n" ;TI" ;TI"D["a"*1023].pack('M') == ("a"*73+"=\n")*14+"a=\n" # => true ;TI"D("a"*73+"=\na=\n").unpack('M') == ["a"*74] # => true ;TI"D(("a"*73+"=\n")*14+"a=\n").unpack('M') == ["a"*1023] # => true ;TI" ;TI"?"a b c\td =\n\ne=\n".unpack('M') # => ["a b c\td \ne"] ;TI"+"=00=\n".unpack('M') # => ["\x00"] ;TI" ;TI":"pre=31=32=33after".unpack('M') # => ["pre123after"] ;TI"7"pre=\nafter".unpack('M') # => ["preafter"] ;TI"7"pre=\r\nafter".unpack('M') # => ["preafter"] ;TI"3"pre=".unpack('M') # => ["pre="] ;TI"5"pre=\r".unpack('M') # => ["pre=\r"] ;TI"7"pre=hoge".unpack('M') # => ["pre=hoge"] ;TI";"pre==31after".unpack('M') # => ["pre==31after"] ;TI"<"pre===31after".unpack('M') # => ["pre===31after"] ;T;0o;;0;[o; ;[ I"+'m' - Base64 encoded string; ;TI"7count specifies input bytes between each newline, ;TI",rounded down to nearest multiple of 3; ;TI".if count is zero, no newlines are added; ;TI"<(see {RFC 4648}[https://www.ietf.org/rfc/rfc4648.txt]):;T@ o;;[(I"([""].pack('m') # => "" ;TI".["\0"].pack('m') # => "AA==\n" ;TI".["\0\0"].pack('m') # => "AAA=\n" ;TI".["\0\0\0"].pack('m') # => "AAAA\n" ;TI".["\377"].pack('m') # => "/w==\n" ;TI".["\377\377"].pack('m') # => "//8=\n" ;TI".["\377\377\377"].pack('m') # => "////\n" ;TI" ;TI"$"".unpack('m') # => [""] ;TI"("AA==\n".unpack('m') # => ["\x00"] ;TI","AAA=\n".unpack('m') # => ["\x00\x00"] ;TI"0"AAAA\n".unpack('m') # => ["\x00\x00\x00"] ;TI"("/w==\n".unpack('m') # => ["\xFF"] ;TI","//8=\n".unpack('m') # => ["\xFF\xFF"] ;TI"0"////\n".unpack('m') # => ["\xFF\xFF\xFF"] ;TI"$"A\n".unpack('m') # => [""] ;TI"("AA\n".unpack('m') # => ["\x00"] ;TI"("AA=\n".unpack('m') # => ["\x00"] ;TI","AAA\n".unpack('m') # => ["\x00\x00"] ;TI" ;TI")[""].pack('m0') # => "" ;TI"-["\0"].pack('m0') # => "AA==" ;TI"-["\0\0"].pack('m0') # => "AAA=" ;TI"-["\0\0\0"].pack('m0') # => "AAAA" ;TI"-["\377"].pack('m0') # => "/w==" ;TI"-["\377\377"].pack('m0') # => "//8=" ;TI"-["\377\377\377"].pack('m0') # => "////" ;TI" ;TI"#"".unpack('m0') # => [""] ;TI"'"AA==".unpack('m0') # => ["\x00"] ;TI"+"AAA=".unpack('m0') # => ["\x00\x00"] ;TI"/"AAAA".unpack('m0') # => ["\x00\x00\x00"] ;TI"'"/w==".unpack('m0') # => ["\xFF"] ;TI"+"//8=".unpack('m0') # => ["\xFF\xFF"] ;TI"/"////".unpack('m0') # => ["\xFF\xFF\xFF"] ;T;0o;;0;[o; ;[I"&'u' - UU-encoded string:;T@ o;;[ I"#[""].pack("u") # => "" ;TI"*["a"].pack("u") # => "!80``\n" ;TI"*["aaa"].pack("u") # => "#86%A\n" ;TI" ;TI"%"".unpack("u") # => [""] ;TI"("#86)C\n".unpack("u") # => ["abc"] ;T;0S; ; i; I"Offset Directives;T@ o;;;;[o;;0;[ o; ;[I"<'@' - Begin packing at the given byte offset; ;TI"3for packing, null fill or shrink if necessary:;T@ o;;[ I")[1, 2].pack("C@0C") # => "\x02" ;TI"-[1, 2].pack("C@1C") # => "\x01\x02" ;TI"=[1, 2].pack("C@5C") # => "\x01\x00\x00\x00\x00\x02" ;TI"1[*1..5].pack("CCCC@2C") # => "\x01\x02\x05" ;T;0o; ;[I"9For unpacking, cannot to move to outside the string:;T@ o;;[I"3"\x01\x00\x00\x02".unpack("C@3C") # => [1, 2] ;TI"2"\x00".unpack("@1C") # => [nil] ;TI"?"\x00".unpack("@2C") # Raises ArgumentError. ;T;0o;;0;[o; ;[I"B'X' - For packing, shrink for the given byte offset:;T@ o;;[I"/[0, 1, 2].pack("CCXC") # => "\x00\x02" ;TI"+[0, 1, 2].pack("CCX2C") # => "\x02" ;T;0o; ;[I"HFor unpacking; rewind unpacking position for the given byte offset:;T@ o;;[I"."\x00\x02".unpack("CCXC") # => [0, 2, 2] ;T;0o; ;[I"*Cannot to move to outside the string:;T@ o;;[I"7[0, 1, 2].pack("CCX3C") # Raises ArgumentError. ;TI"7"\x00\x02".unpack("CX3C") # Raises ArgumentError. ;T;0o;;0;[ o; ;[I"B'x' - Begin packing at after the given byte offset; ;TI")for packing, null fill if necessary:;T@ o;;[I"*[].pack("x0") # => "" ;TI".[].pack("x") # => "\x00" ;TI"J[].pack("x8") # => "\x00\x00\x00\x00\x00\x00\x00\x00" ;T;0o; ;[I"9For unpacking, cannot to move to outside the string:;T@ o;;[I"."\x00\x00\x02".unpack("CxC") # => [0, 2] ;TI"-"\x00\x00\x02".unpack("x3C") # => [nil] ;TI"8"\x00\x00\x02".unpack("x4C") # Raises ArgumentError;T;0: @file@:0@omit_headings_from_table_of_contents_below0