1. 程式人生 > >unity裡做URL編碼,類似java裡的urlEncode,WWW.EscapeURL

unity裡做URL編碼,類似java裡的urlEncode,WWW.EscapeURL

WWW.EscapeURL 編碼網址

static function EscapeURL (s : string, e : Encoding = System.Text.Encoding.UTF8) : string

Parameters引數

  • s A string to be escaped.
    一個字串進行轉義,也就是用來編碼的字串
  • e The encoding to use when converting characters to a character code.
    當轉換字元到一個字元程式碼時,使用編碼encoding,也就是編碼的字符集
Returns

string - A new string with all illegal characters replaced with %xx where xx is the hexadecimal code for the character code.

返回string型別,一個新的字串,用%xx替換所有非法字元,其中xx是十六進位制的字元程式碼。

Description描述

Encodes string into an URL-friendly format.

字串編碼成一個URL的格式。

Replaces illegal characters in s with the correct URL escaped code. Useful when building web page parameters.

使用正確的URL替換非法轉義程式碼,在建立網頁時是非常有用的引數。

// This will print the string "Testing%201%2C2%2C3" to the console
//這將列印字串"Testing%201%2C2%2C3"到控制檯
print(WWW.EscapeURL("Testing 1,2,3"));