📄 isotogbk.java
字号:
以下的代码给你一个参考。
[code]
/** 说明: ISO_8559_1字符转换为GBK字符
* @param 需要转换的字符
* @return 转换后的GBK字符
*/
public static String IsoToGBK(String strIn)
{
String strOut = null;
if(strIn == null) return "";
try
{
byte[] b = strIn.getBytes("ISO8859_1");
strOut = new String(b,"GBK");
}
catch(UnsupportedEncodingException e)
{}
return strOut;
}
/** 说明: GBK字符转换为ISO_8559_1字符
* @param 需要转换的GBK字符
* @return 转换后的ISO_8559_1字符
*/
public static String GBKToIso(String strIn)
{
byte[] b;
String strOut = null;
if(strIn == null) return "";
try
{
b = strIn.getBytes("GBK");
strOut = new String(b,"ISO8859_1");
}
catch(UnsupportedEncodingException e)
{}
return strOut;
}
字符编码转换类2007-05-09 10:01package com.jeasycms.cmsbean;
//中文处理类
public class UnicellEncoder {
public static String isoToGb2312(String str)
{
String strIso=null;
if(str==null) return null;
try{
strIso =new String(str.getBytes("ISO-8859-1"),"gb2312");
}catch(Exception e){
e.printStackTrace();
}
return strIso;
}
public static String isoToGbk(String str)
{
String strIso=null;
if(str==null) return null;
try{
strIso =new String(str.getBytes("ISO-8859-1"),"GBK");
}catch(Exception e){
e.printStackTrace();
}
return strIso;
}
public static String gbkToIso(String str)
{
String strIso=null;
if(str==null) return null;
try{
strIso =new String(str.getBytes("GBK"),"ISO-8859-1");
}catch(Exception e){
e.printStackTrace();
}
return strIso;
}
public static String isoToUtf8(String str) {
String strIso = null;
if (str == null) {
return "";
}
try {
strIso = new String(str.getBytes("ISO-8859-1"), "UTF-8");
}
catch (Exception e) {
e.printStackTrace();
}
return strIso;
}
public static String utf8ToIso(String str) {
String strIso = null;
if (str == null) {
return "";
}
try {
strIso = new String(str.getBytes("UTF-8"), "ISO-8859-1");
}
catch (Exception e) {
e.printStackTrace();
}
return strIso;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -