附一个用于从数据库和网络中取出中文乱码的处理函数,入参是有问题的字符串,出参
是问题已经解决了的字符串。
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;
}
是问题已经解决了的字符串。
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;
}
解决方案 »
- newSingleThreadExecutor的使用场景
- RCP开发的编辑器或不用RCP方式,如何实现拖拽文件到编辑器中的功能?
- 解决问题马上结贴!
- 怎样在JAVA文件中用代码实现创建一个文件?
- Bigger type length than Maximum
- 大家都用什么工具做界面?现在需要用awt做一个界面,我用jdk快累死了,做得也不好看!郁闷...
- 昨天的笔试题目,关于运算符的
- 书上的例题为什么我运行和书上是示例图不一样。
- jdk1.3.0_02的问题!
- GG,我回来了,好久没来,又有新问题!请GG们进来看看哦!还有上次的SWING颜色的框框问题我有新进展!!!
- 我是初学者,请大家帮助我解答我这几个小问题,谁帮我解决了给谁分!!!
- 刚学java,有两个问题,请网友帮我一下!!!!!
可以用 javac -encoding iso-8859-1 youfile.java的方法来解决.
还有http://www.ibm.com.cn/的技术专区有介绍。
我还是同意wxyxl()的作法。
String UNIT = new String(UNIT.getBytes("ISO-8859-1"), "GBK");