免费视频淫片aa毛片_日韩高清在线亚洲专区vr_日韩大片免费观看视频播放_亚洲欧美国产精品完整版
打開APP
未登錄
開通VIP,暢享免費電子書等14項超值服
開通VIP
首頁
好書
留言交流
下載APP
聯系客服
HTMLEscape JavaScriptEscape
燮羽
>《Web前端》
2010.11.27
關注
ava代碼
/**
* Returns a string that is equivalent to the input string, but with
* special characters converted to HTML escape sequences.
*
* @param input the string to escape (<code>null</code> not permitted).
*
* @return A string with characters escaped.
*
* @since 1.0.9
*/
public
static
String htmlEscape(String input) {
if
(input ==
null
) {
throw
new
IllegalArgumentException(
"Null 'input' argument."
);
}
StringBuffer result =
new
StringBuffer();
int
length = input.length();
for
(
int
i =
0
; i < length; i++) {
char
c = input.charAt(i);
if
(c ==
'&'
) {
result.append(
"&"
);
}
else
if
(c ==
'\"'
) {
result.append(
"""
);
}
else
if
(c ==
'<'
) {
result.append(
"<"
);
}
else
if
(c ==
'>'
) {
result.append(
">"
);
}
else
if
(c ==
'\''
) {
result.append(
"'"
);
}
else
if
(c ==
'\\'
) {
result.append(
"\"
);
}
else
{
result.append(c);
}
}
return
result.toString();
}
/**
* Returns a string that is equivalent to the input string, but with
* special characters converted to JavaScript escape sequences.
*
* @param input the string to escape (<code>null</code> not permitted).
*
* @return A string with characters escaped.
*
* @since 1.0.13
*/
public
static
String javascriptEscape(String input) {
if
(input ==
null
) {
throw
new
IllegalArgumentException(
"Null 'input' argument."
);
}
StringBuffer result =
new
StringBuffer();
int
length = input.length();
for
(
int
i =
0
; i < length; i++) {
char
c = input.charAt(i);
if
(c ==
'\"'
) {
result.append(
"\\\""
);
}
else
if
(c ==
'\''
) {
result.append(
"\\'"
);
}
else
if
(c ==
'\\'
) {
result.append(
"\\\\"
);
}
else
{
result.append(c);
}
}
return
result.toString();
}
}
本站僅提供存儲服務,所有內容均由用戶發(fā)布,如發(fā)現有害或侵權內容,請
點擊舉報
。
打開APP,閱讀全文并永久保存
查看更多類似文章
猜你喜歡
類似文章
字符串模式匹配 - 阿咪
漏洞 木馬 cmdjsp.jsp
JavaScript escape/unescape編碼的Java實現
ajax中文上傳編碼問題
java版本的escape和unescape函數
Redis批量導入數據的方法
更多類似文章 >>
生活服務
首頁
萬象
文化
人生
生活
健康
教育
職場
理財
娛樂
藝術
上網
留言交流
回頂部
聯系我們
分享
收藏
點擊這里,查看已保存的文章
導長圖
關注
一鍵復制
下載文章
綁定賬號成功
后續(xù)可登錄賬號暢享VIP特權!
如果VIP功能使用有故障,
可點擊這里聯系客服!
聯系客服
微信登錄中...
請勿關閉此頁面
先別劃走!
送你5元優(yōu)惠券,購買VIP限時立減!
5
元
優(yōu)惠券
優(yōu)惠券還有
10:00
過期
馬上使用
×