綁定帳號登入

Android 台灣中文網

Android 台灣中文網 標籤 換成 相關日誌

tag 標籤: 換成

相關日誌

分享 取讀 BIG5 碼檔案 轉換成 UTF-16LE 文字格式輸出
jianrupan 2020-5-11 17:15
本文說明將 BIG 5 格式的文件檔,讀取後為 Byte 形式,如何轉換為 UTF-16LE 文字格式輸出。 執行方式程式段說明: // 讀取檔案 BufferedInputStream bReader = new BufferedInputStream(new FileInputStream(sFile)); // 讀取 tCnt Byte 放入 Buf 0 開始位置 rCnt = bReader.read(Buf, 0, tCnt); // Byte BIG5 轉為 UTF-16LE sName = StringUtil.MTByte2Str(Buf, "BIG5", "UTF-16LE"); // Byte 文字轉換(exp: BIG5 轉為 UTF-16LE) public static String MTByte2Str (byte =retStr.getBytes(tType); int gCnt = 0; for (gCnt=0; gCnttBuf.length; gCnt++) { if(0 == y ) break; } // Byte 轉為目前 指定文字 Type String (UTF-16LE) retStr = new String(y, 0, gCnt, tType); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } return retStr; }
個人分類: 軟體應用|313 次閱讀|0 個評論