new String(buf.readForRecycle (), 0, len, StandardCharsets.UTF_8), IO.DEFAULT_CHARSET); return connection;
new String(buf.readForRecycle (), 0, len, StandardCharsets.UTF_8), IO.DEFAULT_CHARSET); return connection;
new String( buf.readForRecycle(), 0, len, StandardCharsets.UTF_8 ), IO.DEFAULT_CHARSET ); return connection;
new String( buf.readForRecycle(), 0, len, StandardCharsets.UTF_8 ), IO.DEFAULT_CHARSET ); return connection;
new String( buf.readForRecycle(), 0, len, StandardCharsets.UTF_8 ), IO.DEFAULT_CHARSET ); return connection;
@Test public void readUnsignedInt () { //0x53, 0x2D, 0x78, 0xAA. //http://stackoverflow.com/questions/19874527/conversion-from-bytes-to-large-unsigned-integer-and-string ByteBuf buf = ByteBuf.create ( 20 ); buf.addByte ( 0xAA ); buf.addByte ( 0x78 ); buf.addByte ( 0x2D ); buf.addByte ( 0x53 ); byte[] bytes = buf.readForRecycle ();
@Test public void test2() { ByteBuf buf = new ByteBuf(); buf.add( "abc" ); buf.add( "def" ); boolean ok = true; final byte[] bytes = buf.readForRecycle(); ok |= bytes[ 3 ] == 'd' || die(); }
@Test public void test3() throws UnsupportedEncodingException { ByteBuf buf = new ByteBuf(); buf.add( URLEncoder.encode( "abc", "UTF-8" ) ); buf.addUrlEncodedByteArray( new byte[]{ ( byte ) 1, 2, 3 } ); buf.add( URLEncoder.encode( "def", "UTF-8" ) ); boolean ok = true; final byte[] bytes = buf.readForRecycle(); ok |= bytes[ 3 ] == '%' || die(); ok |= bytes[ 4 ] == '0' || die(); ok |= bytes[ 5 ] == '1' || die(); ok |= bytes[ 6 ] == '%' || die( "" + bytes[ 5 ] ); ok |= bytes[ 7 ] == '0' || die(); ok |= bytes[ 8 ] == '2' || die(); ok |= bytes[ 9 ] == '%' || die(); ok |= bytes[ 10 ] == '0' || die(); ok |= bytes[ 11 ] == '3' || die(); ok |= bytes[ 12 ] == 'd' || die(); }
buf.addByte( 0x53 ); byte[] bytes = buf.readForRecycle(); bytes = buf.readForRecycle(); bytes = buf.readForRecycle();
@Test public void testURLEncodeBytes() { ByteBuf buf = ByteBuf.create( 20 ); buf.addUrlEncodedByteArray( new byte[]{ 0x0, 0x1, 0x2 } ); final byte[] bytes = buf.readForRecycle(); boolean ok = true; ok |= bytes[ 0 ] == '%' || die(); ok |= bytes[ 1 ] == '0' || die(); ok |= bytes[ 2 ] == '0' || die(); ok |= bytes[ 3 ] == '%' || die(); ok |= bytes[ 4 ] == '0' || die(); ok |= bytes[ 5 ] == '1' || die(); ok |= bytes[ 6 ] == '%' || die(); ok |= bytes[ 7 ] == '0' || die(); ok |= bytes[ 8 ] == '2' || die(); }