※ 引述《faraway0203 (123)》之銘言:
: 字串一長串
: 原本其實是中文
: ex:
: String msg =62DC8A17002C6557662F4E005B9A89817684963F00214F604E5F65B05E745FEB6
: A0255370021661F671F59295982679C8981642D4FBF8ECA518D8DDF62118AAA0021;
: 上面為nuicode的編碼格式 每四個為一個中文
: 62DC 是 中文的拜
: 要怎麼可以print出(中文的msg);
: 請問有什麼方法是可以轉換或是改變編碼格式呢?
: 先感謝了~
char psmonkey = (char) Integer.decode("0X62DC").intValue();
System.out.println(psmonkey);
希望能看到不同的方法... [跪拜之 Orz]
--
侃侃長論鮮窒礙 http://www.psmonkey.idv.tw
眾目睽睽無心顫 telnet://legend.twbbs.org
煢居少聊常人事
殺頭容易告白難
拜託不要,我對女案主過敏 \囧/
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 203.204.16.17
> -------------------------------------------------------------------------- <
發信人: lazyf.bbs@cd.twbbs.org (懶魚), 看板: java
標 題: Re: 請問一長串unicode編碼的字串
發信站: 中正築夢園 (Tue Jan 17 02:05:11 2006)
轉信站: ptt!ctu-reader!Spring!ctu-peer!news.nctu!netnews.csie.nctu!Yuntech-New
※ 引述《PsMonkey.bbs@ptt.cc (痞子軍團團長)》之銘言:
> ※ 引述《faraway0203 (123)》之銘言:
> : 字串一長串
> : 原本其實是中文
> : ex:
> : String msg =62DC8A17002C6557662F4E005B9A89817684963F00214F604E5F65B05E745FEB6
> : A0255370021661F671F59295982679C8981642D4FBF8ECA518D8DDF62118AAA0021;
> : 上面為nuicode的編碼格式 每四個為一個中文
> : 62DC 是 中文的拜
> : 要怎麼可以print出(中文的msg);
> : 請問有什麼方法是可以轉換或是改變編碼格式呢?
> : 先感謝了~
> char psmonkey = (char) Integer.decode("0X62DC").intValue();
> System.out.println(psmonkey);
> 希望能看到不同的方法... [跪拜之 Orz]
for(int i=0;i<msg.length();i+=4)
System.out.print((char)Integer.parseInt(msg.substring(i, i+4), 16));
BTW,怕有index的exception的話try catch自己包吧。
--
● ˙ ˙ ◢▇◣ ◢▇◣ ▇ ▇ █▇◣ █▇◣ █▇◣ ◢▇◣ █▇▉ /
˙ ╲ █ █ █ █ █ ▉ █ ▉ █▆ █▆▉ ▉▉▉ ★
◢ ★˙ ◥█◤ ◥█◤ ◥█◤ ██◤ █◥▆ █▆◤ █ ▉ ▉▉▉˙ ◣
CDBBS 中正築夢園BBS站 歡迎蒞臨參觀 cd.twbbs.org (140.123.20.230)
http://cd.twbbs.org◥ * Author: lazyf ★ From: 220.143.212.3 ◤