URLEncoder 無法翻譯空格字符 - URLEncoder not able to translate space character

問題:

I am expecting我期待

System.out.println(java.net.URLEncoder.encode("Hello World", "UTF-8"));

to output:輸出:

Hello%20World

(20 is ASCII Hex code for space) (20 是空格的 ASCII 十六進制代碼)

However, what I get is:但是,我得到的是:

Hello+World

Am I using the wrong method?我使用了錯誤的方法嗎? What is the correct method I should be using?我應該使用的正確方法是什麼?


解決方案:

參考一: https://en.stackoom.com/question/JsWn
參考二: https://stackoom.com/question/JsWn
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章