跳至主要內容

對 URI 元件進行編碼 (string.encode_uri_component)

聲明​

編碼後的 URI 元件 = string.encode_uri_component(URI 元件)

參數​

  • URI 元件
    字串型,URI 元件

回傳值​

  • 編碼後的 URI 元件
    文字型,返回編碼後的 URI 元件

說明​

對 URI 元件中的特殊字元進行百分號編碼;相比 string.encode_uri,會更為嚴格地轉義 /、?、&、= 等保留字元
關鍵詞:URI 元件編碼
該函式在 20250313 以後版本方可使用

範例​

nLog(string.encode_uri_component("https://www.example.com/测试")) -- https%3A%2F%2Fwww.example.com%2F%E6%B5%8B%E8%AF%95