@Test
public void testDecode() throws Exception {

    StringCodec codec = new StringCodec();
    // UTF8
    Assert.assertArrayEquals(new byte[] { (byte) 0xe8, (byte) 0xaa, (byte) 0xb0, 0x20 }, codec.encode("誰", 32));
    // GBK
    codec.setEncoding("GBK");
    Assert.assertArrayEquals(new byte[] { (byte) 0xb3, (byte) 0xc2, (byte) 0x20, 0x20 }, codec.encode("陈", 32));
    // SPACE char => 0x00
    codec.setEmptyByte("00");
    Assert.assertArrayEquals(new byte[] { (byte) 0xb3, (byte) 0xc2, (byte) 0x00, 0x00 }, codec.encode("陈", 32));
}