FreeOZ论坛

标题: Netty的BASE64实现有bug? [打印本页]

作者: key    时间: 13-1-2010 08:51
标题: Netty的BASE64实现有bug?
我自己写了一个encodeString的方法来调用Netty的base64编解码器,
结果发现某些字符串编码出错。
比如
hello 没错
world parameters 有错
  1.     public static String encodeString(String input){
  2.         byte[] xb = input.getBytes();
  3.         ChannelBuffer cb = ChannelBuffers.wrappedBuffer(xb);
  4.         //cb = Base64.encode(cb, Base64Dialect.URL_SAFE);
  5.         cb = Base64.encode(cb, cb.readerIndex(), cb.readableBytes(), false, Base64Dialect.STANDARD);
  6.         int len = cb.readableBytes();
  7.         byte[] contentBytes = new byte[len];
  8.         cb.readBytes(contentBytes);
  9.         String output = new String(contentBytes);
  10.         return output;
  11.     }
复制代码

作者: key    时间: 13-1-2010 09:19
不得已,换用Apache Common Codec中的Base64实现了

原帖由 key 于 13-1-2010 09:51 发表
我自己写了一个encodeString的方法来调用Netty的base64编解码器,
结果发现某些字符串编码出错。
比如
hello 没错
world parameters 有错    public static String encodeString(String input){
        byte[] ...





欢迎光临 FreeOZ论坛 (https://www.freeoz.org/ibbs/) Powered by Discuz! X3.2