String str = "";
try
{
str = new String(EncodingString.getBytes("UTF-8"),
"GBK");
} catch (UnsupportedEncodingException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
try
{
str = new String(EncodingString.getBytes("UTF-8"),
"GBK");
} catch (UnsupportedEncodingException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
import java.io.UnsupportedEncodingException;public class DbEncoding
{
public static String STR_DB_ENCODING = "UTF-8"; public static String STR_WEB_ENCODING = "GBK"; public static String Encoding(String EncodingString)
{
String str = "";
try
{
str = new String(EncodingString.getBytes(STR_DB_ENCODING),
STR_WEB_ENCODING);
} catch (UnsupportedEncodingException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
return str;
}
public static String Decoding(String DecodingString)
{
String str = "";
try
{
str = new String(DecodingString.getBytes(STR_WEB_ENCODING),
STR_DB_ENCODING);
} catch (UnsupportedEncodingException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
return str;
}
}
下面有:http://www.cn-java.com/target/news.php?news_id=992http://www.javaresearch.org/article/showarticle.jsp?column=546&thread=17716
unicode到中文:
native2ascii -reverse -encoding gb2312 sourcefile targetfile
中文到unicode:
native2ascii sourcefile targetfile