Package org.jruby.util
Class Pack
java.lang.Object
org.jruby.util.Pack
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic IRubyObject
decode
(ThreadContext context, ByteBuffer encode, int occurrences, RubyArray result, Block block, Pack.Converter converter, int mode) static void
decode
(ThreadContext context, Ruby runtime, ByteBuffer encode, int occurrences, RubyArray result, Block block, Pack.Converter converter) Deprecated.static int
getDirective
(ThreadContext context, String mode, ByteList formatString, ByteBuffer encode) static RubyString
Deprecated.static RubyString
pack
(ThreadContext context, RubyArray list, RubyString formatString, RubyString buffer) static RubyString
pack
(ThreadContext context, Ruby runtime, RubyArray list, RubyString formatString) Deprecated.static ByteList
static int
safeGet
(ByteBuffer encode) static RubyArray
Deprecated.static RubyArray
unpack
(ThreadContext context, RubyString encoded, ByteList formatString) static RubyArray
unpack
(ThreadContext context, ByteList encodedString, ByteList formatString) static IRubyObject
unpack1WithBlock
(ThreadContext context, RubyString encoded, ByteList formatString, long offset, Block block) static IRubyObject
unpack1WithBlock
(ThreadContext context, RubyString encoded, ByteList formatString, Block block) static int
unpackInt_i
(ByteBuffer enc) static RubyArray
unpackWithBlock
(ThreadContext context, Ruby runtime, ByteList encodedString, ByteList formatString, Block block) Deprecated.static RubyArray
unpackWithBlock
(ThreadContext context, RubyString encoded, ByteList formatString, long offset, Block block) static RubyArray
unpackWithBlock
(ThreadContext context, RubyString encoded, ByteList formatString, Block block) Decodes str (which may contain binary data) according to the format string, returning an array of each value extracted.static int
utf8Decode
(Ruby runtime, byte[] to, int p, int code) rb_uv_to_utf8
-
Field Details
-
sHexDigits
public static final byte[] sHexDigits -
b64_xtable
public static final int[] b64_xtable
-
-
Constructor Details
-
Pack
public Pack()
-
-
Method Details
-
unpackInt_i
-
packInt_i
-
unpack
public static RubyArray unpack(ThreadContext context, ByteList encodedString, ByteList formatString) -
unpack
- Parameters:
context
-encoded
-formatString
-- Returns:
- unpacked array
- See Also:
-
unpackWithBlock
public static RubyArray unpackWithBlock(ThreadContext context, RubyString encoded, ByteList formatString, Block block) Decodes str (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.
Each directive may be followed by a number, indicating the number of times to repeat with this directive. An asterisk (``*
'') will use up all remaining elements.
Note that if passed a block, this method will return null and instead yield results to the block. The directivessSiIlL
may each be followed by an underscore (``_
'') 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.Directives for String#unpack
1 May be modified by appending ``_'' to the directive.Format Function Returns A String with trailing nulls and spaces removed. String a String. String B Extract bits from each character (msb first). String b Extract bits from each character (lsb first). String C Extract a character as an unsigned integer. Fixnum c Extract a character as an integer. Fixnum d Treat sizeof(double) characters as a native double. Float E Treat sizeof(double) characters as a double in little-endian byte order. Float e Treat sizeof(float) characters as a float in little-endian byte order. Float f Treat sizeof(float) characters as a native float. Float G Treat sizeof(double) characters as a double in network byte order. Float g Treat sizeof(float) characters as a float in network byte order. Float H Extract hex nibbles from each character (most significant first). String h Extract hex nibbles from each character (least significant first). String I Treat sizeof(int) 1 successive characters as an unsigned native integer. Integer i Treat sizeof(int) 1 successive characters as a signed native integer. Integer L Treat four1 successive characters as an unsigned native long integer. Integer l Treat four1 successive characters as a signed native long integer. Integer M Extract a quoted-printable string. String m Extract a base64 encoded string. String N Treat four characters as an unsigned long in network byte order. Fixnum n Treat two characters as an unsigned short in network byte order. Fixnum P Treat sizeof(char *) characters as a pointer, and return len characters from the referenced location. String p Treat sizeof(char *) characters as a pointer to a null-terminated string. String S Treat two1 successive characters as an unsigned short in native byte order. Fixnum s Treat two1 successive characters as a signed short in native byte order. Fixnum U Extract UTF-8 characters as unsigned integers. Integer u Extract a UU-encoded string. String V Treat four characters as an unsigned long in little-endian byte order. Fixnum v Treat two characters as an unsigned short in little-endian byte order. Fixnum X Skip backward one character. --- x Skip forward one character. --- Z String with trailing nulls removed. String @ Skip to the offset given by the length argument. --- - See Also:
-
unpackWithBlock
public static RubyArray unpackWithBlock(ThreadContext context, RubyString encoded, ByteList formatString, long offset, Block block) -
unpack1WithBlock
public static IRubyObject unpack1WithBlock(ThreadContext context, RubyString encoded, ByteList formatString, Block block) -
unpack1WithBlock
public static IRubyObject unpack1WithBlock(ThreadContext context, RubyString encoded, ByteList formatString, long offset, Block block) -
utf8Decode
rb_uv_to_utf8 -
safeGet
-
getDirective
public static int getDirective(ThreadContext context, String mode, ByteList formatString, ByteBuffer encode) -
decode
public static IRubyObject decode(ThreadContext context, ByteBuffer encode, int occurrences, RubyArray result, Block block, Pack.Converter converter, int mode) -
pack
public static RubyString pack(ThreadContext context, RubyArray list, RubyString formatString, RubyString buffer) -
unpack
@Deprecated public static RubyArray unpack(Ruby runtime, ByteList encodedString, ByteList formatString) Deprecated. -
pack
Deprecated. -
pack
@Deprecated public static RubyString pack(ThreadContext context, Ruby runtime, RubyArray list, RubyString formatString) Deprecated. -
decode
@Deprecated public static void decode(ThreadContext context, Ruby runtime, ByteBuffer encode, int occurrences, RubyArray result, Block block, Pack.Converter converter) Deprecated. -
unpackWithBlock
@Deprecated public static RubyArray unpackWithBlock(ThreadContext context, Ruby runtime, ByteList encodedString, ByteList formatString, Block block) Deprecated.
-