免费视频淫片aa毛片_日韩高清在线亚洲专区vr_日韩大片免费观看视频播放_亚洲欧美国产精品完整版

打開APP
userphoto
未登錄

開通VIP,暢享免費電子書等14項超值服

開通VIP
HTMLEscape JavaScriptEscape
ava代碼 
  1. /** 
  2.      * Returns a string that is equivalent to the input string, but with 
  3.      * special characters converted to HTML escape sequences. 
  4.      * 
  5.      * @param input the string to escape (<code>null</code> not permitted). 
  6.      * 
  7.      * @return A string with characters escaped. 
  8.      * 
  9.      * @since 1.0.9 
  10.      */  
  11.     public static String htmlEscape(String input) {  
  12.         if (input == null) {  
  13.             throw new IllegalArgumentException("Null 'input' argument.");  
  14.         }  
  15.         StringBuffer result = new StringBuffer();  
  16.         int length = input.length();  
  17.         for (int i = 0; i < length; i++) {  
  18.             char c = input.charAt(i);  
  19.             if (c == '&') {  
  20.                 result.append("&");  
  21.             }  
  22.             else if (c == '\"') {  
  23.                 result.append(""");  
  24.             }  
  25.             else if (c == '<') {  
  26.                 result.append("<");  
  27.             }  
  28.             else if (c == '>') {  
  29.                 result.append(">");  
  30.             }  
  31.             else if (c == '\'') {  
  32.                 result.append("'");  
  33.             }  
  34.             else if (c == '\\') {  
  35.                 result.append("\");  
  36.             }  
  37.             else {  
  38.                 result.append(c);  
  39.             }  
  40.         }  
  41.         return result.toString();  
  42.     }  
  43.   
  44.     /** 
  45.      * Returns a string that is equivalent to the input string, but with 
  46.      * special characters converted to JavaScript escape sequences. 
  47.      * 
  48.      * @param input the string to escape (<code>null</code> not permitted). 
  49.      * 
  50.      * @return A string with characters escaped. 
  51.      * 
  52.      * @since 1.0.13 
  53.      */  
  54.     public static String javascriptEscape(String input) {  
  55.         if (input == null) {  
  56.             throw new IllegalArgumentException("Null 'input' argument.");  
  57.         }  
  58.         StringBuffer result = new StringBuffer();  
  59.         int length = input.length();  
  60.         for (int i = 0; i < length; i++) {  
  61.             char c = input.charAt(i);  
  62.             if (c == '\"') {  
  63.                 result.append("\\\"");  
  64.             }  
  65.             else if (c == '\'') {  
  66.                 result.append("\\'");  
  67.             }  
  68.             else if (c == '\\') {  
  69.                 result.append("\\\\");  
  70.             }  
  71.             else {  
  72.                 result.append(c);  
  73.             }  
  74.         }  
  75.         return result.toString();  
  76.     }  
  77. }  
本站僅提供存儲服務,所有內容均由用戶發(fā)布,如發(fā)現有害或侵權內容,請點擊舉報。
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
字符串模式匹配 - 阿咪
漏洞 木馬 cmdjsp.jsp
JavaScript escape/unescape編碼的Java實現
ajax中文上傳編碼問題
java版本的escape和unescape函數
Redis批量導入數據的方法
更多類似文章 >>
生活服務
分享 收藏 導長圖 關注 下載文章
綁定賬號成功
后續(xù)可登錄賬號暢享VIP特權!
如果VIP功能使用有故障,
可點擊這里聯系客服!

聯系客服