01 | import java.io.UnsupportedEncodingException; |
02 | |
03 | public class Bean { |
04 | |
05 | // 将GBK转换为Unicode的代码 |
06 | public String GBK2UNI(String s) throws UnsupportedEncodingException { |
07 | String temp = s; |
08 | temp = new String(s.getBytes( "GBK" ), "ISO8859_1" ); |
09 | return temp; |
10 | } |
11 | |
12 | // 将Unicode转换为GBK的代码 |
13 | public String UNI2GBK(String s) throws UnsupportedEncodingException { |
14 | String temp = s; |
15 | temp = new String(s.getBytes( "ISO8859_1" ), "GBK" ); |
16 | return temp; |
17 | } |
18 | |
19 | } |
gbk 与 unicode编码的相互转换 - 云代码
http://yuncode.net/code/c_505fed71643d025