@Test
    public void testCumbersomeEncoding() {
        String[] a = {"abc", "def", "ghi\u00e8"};
        int[] aLens = {3, 3, 5};
        CharsetEncoder ce = Utf8.getNewEncoder();
        ByteBuffer forWire = ByteBuffer.allocate(500);

        for (int i = 0; i < a.length; i++) {
            forWire.putInt(aLens[i]);
            Utf8.toBytes(a[i], 0,
                         a[i].length(), forWire, ce);
        }
        forWire.flip();
        int totalLimit = forWire.limit();
        for (String anA : a) {
            int len = forWire.getInt();
            forWire.limit(forWire.position() + len);
            String s = Utf8.toString(forWire);
            assertEquals(anA, s);
            forWire.limit(totalLimit);
        }
        assertEquals(0, forWire.remaining());
    }
@author <a href="mailto:borud@yahoo-inc.com">Bjorn Borud</a>
@author <a href="mailto:steinar@yahoo-inc.com">Steinar Knutsen</a>
vespajlib/src/test/java/com/yahoo/text/Utf8TestCase.java