static void check(CharSequence str) throws Exception
    {
        byte[] builtin = str.toString().getBytes("UTF-8");
        LinkedBuffer lb = new LinkedBuffer(512);
        WriteSession session = new WriteSession(lb);

        StringSerializer.writeUTF8(str, session, lb);

        assertTrue(builtin.length == session.size);

        byte[] buffered = session.toByteArray();

        assertTrue(builtin.length == buffered.length);

        String strBuiltin = new String(builtin, "UTF-8");
        String strBuffered = new String(buffered, "UTF-8");

        assertEquals(strBuiltin, strBuffered);
        print(strBuiltin);
        print("len: " + builtin.length);
    }
Tests for UTF-8 Encoding

@author David Yu
@created Jul 6, 2010
protostuff-api/src/test/java/io/protostuff/StringSerializerTest.java