当前所在位置:珠峰网资料 >> 计算机 >> 计算机等级考试 >> 正文
用于数据库和网络中取出中文乱码的处理函数
发布时间:2010/7/30 10:16:01 来源:城市学习网 编辑:ziteng
  当然,在这种方案未被采用之前,还是希望 Java Soft 能够严格地测试它的产品,为用户带来更多的方便。附一个用于从数据库和网络中取出中文乱码的处理函数,入参是有问题的字符串,出参是问题已经解决了的字符串。
  String parseChinese(String in)
  {
  String s = null;
  byte temp [];
  if (in == null)
  {
  System.out.println("Warn:Chinese null founded!");
  return new String("");
  }
  try
  {
  temp=in.getBytes("iso-8859-1");
  temp=in.getBytes("iso-8859-1");
  s = new String(temp);
  }
  {
  System.out.println("Warn:Chinese null founded!");
  return new String("");
  }
  try
  {
  temp=in.getBytes("iso-8859-1");
  s = new String(temp);
  }
  catch(UnsupportedEncodingException e)
  {
  System.out.println (e.toString());
  }
  return s;
  }
广告合作:400-664-0084 全国热线:400-664-0084
Copyright 2010 - 2017 www.my8848.com 珠峰网 粤ICP备15066211号
珠峰网 版权所有 All Rights Reserved