中文乱码问题
2002-11-19 14:56
399 查看
/*
编码转换,确保写数据库的时候不会出现乱码
*/
package dbJavaBean;
public class CodingConvert
{
public CodingConvert()
{
//
}
public String toGb(String uniStr){
String gbStr = "";
if(uniStr == null){
uniStr = "";
}
try{
byte[] tempByte = uniStr.getBytes("ISO8859_1");
gbStr = new String(tempByte,"GB2312");
}
catch(Exception ex){
}
return gbStr;
}
public String toUni(String gbStr){
String uniStr = "";
if(gbStr == null){
gbStr = "";
}
try{
byte[] tempByte = gbStr.getBytes("GB2312");
uniStr = new String(tempByte,"ISO8859_1");
}catch(Exception ex){
}
return uniStr;
}
}
编码转换,确保写数据库的时候不会出现乱码
*/
package dbJavaBean;
public class CodingConvert
{
public CodingConvert()
{
//
}
public String toGb(String uniStr){
String gbStr = "";
if(uniStr == null){
uniStr = "";
}
try{
byte[] tempByte = uniStr.getBytes("ISO8859_1");
gbStr = new String(tempByte,"GB2312");
}
catch(Exception ex){
}
return gbStr;
}
public String toUni(String gbStr){
String uniStr = "";
if(gbStr == null){
gbStr = "";
}
try{
byte[] tempByte = gbStr.getBytes("GB2312");
uniStr = new String(tempByte,"ISO8859_1");
}catch(Exception ex){
}
return uniStr;
}
}
相关文章推荐
- 千年零一虫
- ATL实现Connection Point的一种简单的方法
- 独具量身定做特色的管理软件--数据大师
- delphi中的时间操作技术(2)
- IP地址的隐藏(delphi实现 )
- 解析IP地址为主机域名
- 将某一主机域名解析为IP地址
- 力争最简单把*、&说清楚
- 怎样为任何控件和区域添加提示信息:用自己封装的CTip类
- 用VB和MTS开发多层数据库应用系统
- 使用C#开发COM+组件
- DOM心得
- Java 2 Micro Edition简介(二)
- 通过SDK函数实现WIN32应用程序的唯一实例。
- WIN32 SDK - 捕获鼠标离开和滞留等事件
- 用VxD技术设计网络计费系统
- zabbix proxy配置文件不能把DBhost设置成远程数据库?