何時使用atob,encodeURIComponent,btoa,decodeURIComponent。它們是否可以一起使用,即atob(encodeURIComponent(...))?如果不是,那麼何時將使用bobo_&以及何時將encodeURIComponent & decodeURIComponent被使用。何時使用atob,encodeURIComponent和btoa,decodeURIComponent
0
A
回答
2
btoa()
以base-64格式編碼一串二進制數據。這最常用的用途是從文件內容創建一個data:
URI(例如,將JPEG或GIF文件轉換爲您直接合併到頁面中的URI,而不是引用遠程文件)。
atob()
執行相反的操作:給定一個base-64字符串,它返回二進制數據。
encodeURIComponent()
用於執行將在URI中使用的字符串的URL編碼。這將在URI中具有特殊含義的字符轉換爲%
,然後是十六進制編碼,例如,空間變成%20
。這通常用於創建將在重定向或AJAX請求中使用的URL參數,或將在XMLHTTPRequest.send()
中發送的數據。
decodeURIComponent()
執行encodeURIComponent()
的反轉,所以如果您有"foo%20bar"
它將返回"foo bar"
。
這很少見,您需要將URL編碼和base-64一起用於同一個字符串。
相關問題
- 1. decodeURIComponent(encodeURIComponent(string))的結果是什麼?
- 2. 使用atob()
- 3. 在Jasmine和瀏覽器中使用btoa
- 4. React Native atob()/ btoa()不能在沒有遠程JS調試的情況下工作
- 5. 使用decodeURIComponent的問題
- 6. encodeURIComponent和mysql_real_escape_string
- 7. 如何在asp中使用decodeURIComponent?
- 8. 上decodeURIComponent
- 9. 如何解碼在URL url使用encodeURIComponent()
- 10. decodeURIComponent for postgres
- 11. 使用單個隊列的MQ AtoB和AtoC通信?
- 12. decodeURIComponent(uri)不工作?
- 13. 使用javascript encodeURIComponent函數編碼空格
- 14. 如何在Facebook中使用JS中的decodeURIComponent?
- 15. 使用encodeURIComponent方法和服務器端的
- 16. encodeURIComponent的效率如何?
- 17. 笨+ encodeURIComponent方法
- 18. encodeURIComponent真的很有用嗎?
- 19. 如何模仿C++中的js decodeURIComponent?
- 20. 用Python解析decodeURIComponent JSON字符串
- 21. atob在IE中不工作
- 22. laravel aTob表格關係
- 23. jquery的序列化和encodeURIComponent方法
- 24. encodeURIComponent方法()的區別和[A○]字符
- 25. encodeURIComponent和urldecode刪除斜槓,爲什麼?
- 26. Javascript encodeURIComponent和Java解碼問題
- 27. 如何解碼使用encodeURIComponent()在JS中編碼的HTML?
- 28. 如何在encodeURIComponent(「+」)中保留+號?
- 29. Dynamics CRM Web Api功能:使用encodeURIComponent時路徑中的非法字符
- 30. decodeURIComponent既能正常工作又不能同時工作?
感謝您的回覆。我很感激。 – helfi