Re: [問題] 有沒有方法將字串中的非英文部分轉成它 …
※ 引述《yamamura (sadako)》之銘言:
: 大家好
: 是這樣的,我做了一隻程式只想餵它英文,但很多句子裡面都同時包含多種語言
: 像中英文參雜等,它們都用utf8的格式儲存字符
: 想請問有沒有函數可以將非英數字的其他語系字符轉換成英數字型態的編碼格式
: 當然過程中原本是英數字的地方不會改變
: 先謝過各位高手了!
呃, 你這個需求還頗奇怪....
在 java 裡 char 和 String 都是 unicode
所以你只要把它讀成 String 就可以套進去用
至於讀成 String 的方法 你可以先讀進 byte[]
再使用 new String(bytearray, Charset.forName("UTF-8")) 轉成 String 即可
--
'You've sort of made up for it tonight,' said Harry. 'Getting the
sword. Finishing the Horcrux. Saving my life.'
'That makes me sound a lot cooler then I was,' Ron mumbled.
'Stuff like that always sounds cooler then it really was,' said
Harry. 'I've been trying to tell you that for years.'
-- Harry Potter and the Deathly Hollows, P.308
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.112.30.138
推
04/01 22:25, , 1F
04/01 22:25, 1F
→
04/02 07:50, , 2F
04/02 07:50, 2F