如何將unicode字符串轉換爲ascii爲友好的url創建一個漂亮的字符串?javascript - 如何將unicode字符串轉換爲ascii
2
A
回答
9
只有一個short list of characters可以安全地通過URL的路徑組件。
unreserved = ALPHA/DIGIT/"-"/"."/"_"/"~"
所有其他角色將不得不被刪除(如果你正在創建一個「slu」「)或逃脫。
刪除可以用正則表達式/[^a-zA-Z0-9-._~]/
完成。
轉義可以用encodeURIComponent()
完成。
如果您希望實現ICONV音譯的等效(即,把é
到e
和€
爲EUR
),你必須做你自己,雖然你可以leverage existing solutions也許變換transliteration table到JS格式。
+0
爲我工作!與其他方法相比也很容易。 – Lodewijk 2014-08-04 02:50:34
相關問題
- 1. 將Unicode字符串轉換爲ASCII
- 2. Python:將ascii字符串轉換爲unicode字符串
- 3. 將Unicode字符轉換爲擴展ASCII
- 4. 如何將Unicode值轉換爲ASCII字符串?
- 5. 如何將Unicode字符串轉換爲java中的ASCII碼
- 6. 如何將混合ascii和unicode轉換爲JavaScript中的字符串?
- 7. 將字符串轉換爲字符ascii
- 8. 將字符串轉換爲ascii和ascii爲字符串
- 9. 如何將包含unicode字符的字符串轉換爲unicode?
- 10. 如何將unicode JavaScript字符串轉換爲字節數組?
- 11. 如何將utf8字符串轉換爲ascii字符串?
- 12. Java:如何將ASCII字符串轉換爲字符串?
- 13. 何時將unicode轉換爲字符串?
- 14. 將字符串轉換爲ASCII和ASCII字符串
- 15. unicode字符串轉換到一個轉義ASCII字符串
- 16. 如何在JavaScript中將字符串轉換爲ASCII格式?
- 17. 將Unicode字符串轉換爲Python中的ASCII 2.7
- 18. 將等效的unicode字符串轉換爲Java中的ASCII碼?
- 19. PHP - 在混合字符串中將ASCII轉換爲Unicode
- 20. 如何將字符串轉換爲Perl中的unicode字符串
- 21. 如何將Unicode編碼的字符串轉換爲字符串
- 22. 將unicode轉換爲ascii
- 23. 將unicode URL轉換爲ASCII
- 24. 如何將unicode字符轉換爲delphi 7中的ascii代碼?
- 25. 如何將unicode轉換爲ASCII?
- 26. 如何將字符串轉換爲unicode字符?
- 27. Javascript,將unicode字符串轉換爲Javascript轉義?
- 28. 在JavaScript中將字符轉換爲ASCII
- 29. 如何將unicode字符轉換爲c#中的轉義ascii等效字符#
- 30. 將Ascii字符串轉換爲位流
這必須是重複的 – hop 2010-01-08 14:03:24
http://stackoverflow.com/questions/626792/converting-uto-u-in-javascript http://stackoverflow.com/questions/286921/javascript-equivalent-of-xpaths -translate – hop 2010-01-08 14:26:34
和谷歌的「音譯」 – hop 2010-01-08 14:27:04