當前位置: 首頁>>代碼示例 >>用法及示例精選 >>正文


Javascript unescape()用法及代碼示例


先決條件:JavaScript | escape()

JavaScript中的unescape()函數將字符串作為參數,並用於解碼由escape()函數編碼的字符串。通過unescape()解碼時,字符串中的十六進製序列將替換為它們所代表的字符。

用法:


unescape(string)
<script> 
  
// Special character encoded with 
// escape function 
var str = escape("Geeks for Geeks!!!"); 
document.write("Encoded:" + str); 
  
// New Line 
document.write("<br>"); 
  
// unescape() function 
document.write("Decoded:" + unescape(str)) 
  
// New Line 
document.write("<br><br>"); 
  
// The exception 
// @ and . not encoded. 
str = escape("To contribute articles contact us" +  
                "at contribute@geeksforgeeks.org") 
document.write("Encoded:" + str); 
  
// New Line 
document.write("<br>"); 
  
// unescape() function 
document.write("Decoded:" + unescape(str)) 
  
</script>

輸出:

Encoded:Geeks%20for%20Geeks%21%21%21
Decoded:Geeks for Geeks!!!

Encoded:To%20contribute%20articles%20contact%20us%20at%20contribute@geeksforgeeks.org
Decoded:To contribute articles contact us at contribute@geeksforgeeks.org


相關用法


注:本文由純淨天空篩選整理自ShivamKD大神的英文原創作品 JavaScript | unescape() with examples。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。