- 論壇徽章:
- 0
|
FTP客戶端中如何顯示中文?
以下的代碼給你一個參考。
- /** 說明: ISO_8559_1字符轉(zhuǎn)換為GBK字符
- * @param 需要轉(zhuǎn)換的字符
- * @return 轉(zhuǎn)換后的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字符轉(zhuǎn)換為ISO_8559_1字符
- * @param 需要轉(zhuǎn)換的GBK字符
- * @return 轉(zhuǎn)換后的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;
- }
復制代碼 |
|