UNICODE中文怎样转成GBK中文?

bokei 2003-02-27 11:51:12
客户端用的是FlashMX,它传过来的中文都是UTF-8的,每个汉字3 byte,怎样可以转成GB码的2 byte汉字?
...全文
141 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
redv 2003-02-28
  • 打赏
  • 举报
回复
try this:

new String(strFromFlash.getBytes("UTF-8"), "GB2312");
zxhong 2003-02-28
  • 打赏
  • 举报
回复
public static String UnicodeToChinese(String s){
try{
if(s==null||s.equals("")) return "";
String newstring=null;
newstring=new String(s.getBytes("ISO8859_1"),"gb2312");
return newstring;
}
catch(UnsupportedEncodingException e)
{
return s;
}
}

public static String ChineseToUnicode(String s){
try{
if(s==null||s.equals("")) return "";
String newstring=null;
newstring=new String(s.getBytes("gb2312"),"ISO8859_1");
return newstring;
}
catch(UnsupportedEncodingException e)
{
return s;
}
}

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧