在 Ktor 中有這三個String擴展功能。
從語意上講,它們的作用幾乎很清楚(不完全清楚)。
實際上,我不確定他們做了什么。
如果我想對 url 路徑 ( ) 的一部分進行編碼,like/<<this>>/here我應該使用什么?
如果我想編碼一個可能包含/我不想轉義的字符的字串(即hello/beautiful/world)?
如果我想對同時包含/和 空格或 http 特殊字符的字串進行編碼,例如:this/is seriously/weird?
如果我想對進入查詢引數的字串進行編碼?
如果我想編碼一個既是查詢引數的鍵又是值的字串?
uj5u.com熱心網友回復:
如果我想對 url 路徑的一部分(如/<<this>>/here)進行編碼,我應該使用什么?
"<<this>>".encodeURLPathPart()
如果我想編碼一個可能包含我不想轉義的 / 字符的字串(即 hello/beautiful/world)?
"hello/beautiful/world".encodeURLPath()
如果我想對包含 / 和空格或 http 特殊字符的字串進行編碼,例如:this/is Seriously/weird?
// It depends on how do you want to encode it
"this/is seriously/weird".encodeURLParameter(spaceToPlus = true)
"this/is seriously/weird".encodeURLParameter()
"this/is seriously/weird".encodeURLPathPart()
如果我想對進入查詢引數的字串進行編碼?
如果我想編碼一個既是查詢引數的鍵又是值的字串?
"param key/value".encodeURLQueryComponent(encodeFull = true)
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/510613.html
