-
Notifications
You must be signed in to change notification settings - Fork 0
/
html.htm
30 lines (30 loc) · 2.07 KB
/
html.htm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<!DOCTYPE html>
<html lang="en">
<head profile="http://a9.com/-/spec/opensearch/1.1/">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="./site.css" rel="stylesheet">
<title>html</title>
</head>
<body>
<div class="container">
<h2 id="pkg-overview">package html</h2>
<p><code>import "html"</code>
<p>html包提供了用于转义和解转义HTML文本的函数。</p>
<h3 id="pkg-index" class="section-header">Index <a class="permalink" href="#pkg-index">¶</a></h3>
<a href="../main.html"><h3>返回首页</h3></a>
</br>
<li><a href="#EscapeString">func EscapeString(s string) string</a></li>
<li><a href="#UnescapeString">func UnescapeString(s string) string</a> </li>
</ul>
<h3 id="EscapeString">func <a title="View Source" href="https://github.com/golang/go/blob/master/src/html/escape.go?name=release#229">EscapeString</a> <a class="permalink" href="#pkg-index">¶</a></h3>
<pre class="funcdecl">func EscapeString(s <a href="builtin.htm#string">string</a>) <a href="builtin.htm#string">string</a></pre>
<p align="left">EscapeString函数将特定的一些字符转为逸码后的字符实体,如"<"变成"&lt;"。</p>
<p align="left">它只会修改五个字符:<、>、&、'、"。</p>
<p align="left">UnescapeString(EscapeString(s)) == s总是成立,但是两个函数顺序反过来则不一定成立。</p>
<h3 id="UnescapeString">func <a title="View Source" href="https://github.com/golang/go/blob/master/src/html/escape.go?name=release#243">UnescapeString</a> <a class="permalink" href="#pkg-index">¶</a></h3>
<pre class="funcdecl">func UnescapeString(s <a href="builtin.htm#string">string</a>) <a href="builtin.htm#string">string</a></pre>
<p>UnescapeString函数将逸码的字符实体如"&lt;"修改为原字符"<"。它会解码一个很大范围内的字符实体,远比函数EscapeString转码范围大得多。例如"&aacute;"解码为"á","&#225;"和"&xE1;"也会解码为该字符。</p>
</div>
</body>
</html>