找回密码
 FreeOZ用户注册
查看: 2074|回复: 1
打印 上一主题 下一主题

Netty的BASE64实现有bug?

[复制链接]
跳转到指定楼层
1#
发表于 13-1-2010 09:51:53 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有帐号?FreeOZ用户注册

x
我自己写了一个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.     }
复制代码
回复  

使用道具 举报

2#
 楼主| 发表于 13-1-2010 10:19:38 | 只看该作者
不得已,换用Apache Common Codec中的Base64实现了

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

使用道具 举报

您需要登录后才可以回帖 登录 | FreeOZ用户注册

本版积分规则

小黑屋|手机版|Archiver|FreeOZ论坛

GMT+11, 5-3-2025 03:22 , Processed in 0.032117 second(s), 18 queries , Gzip On, Redis On.

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表