forked from alexaubry/HTMLString
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathString.html
More file actions
285 lines (265 loc) · 10.7 KB
/
Copy pathString.html
File metadata and controls
285 lines (265 loc) · 10.7 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
<!DOCTYPE html>
<html lang="en">
<head>
<title>String Extension Reference</title>
<link rel="stylesheet" type="text/css" href="../css/jazzy.css" />
<link rel="stylesheet" type="text/css" href="../css/highlight.css" />
<meta charset='utf-8'>
<script src="../js/jquery.min.js" defer></script>
<script src="../js/jazzy.js" defer></script>
</head>
<body>
<a name="//apple_ref/swift/Extension/String" class="dashAnchor"></a>
<a title="String Extension Reference"></a>
<header>
<div class="content-wrapper">
<p><a href="../index.html">HTMLString Docs</a> (100% documented)</p>
<p class="header-right"><a href="https://github.com/alexaubry/HTMLString"><img src="../img/gh.png"/>View on GitHub</a></p>
<p class="header-right"><a href="dash-feed://https%3A%2F%2Falexaubry%2Egithub%2Eio%2Fdocsets%2FHTMLString%2Exml"><img src="../img/dash.png"/>Install in Dash</a></p>
</div>
</header>
<div class="content-wrapper">
<p id="breadcrumbs">
<a href="../index.html">HTMLString Reference</a>
<img id="carat" src="../img/carat.png" />
String Extension Reference
</p>
</div>
<div class="content-wrapper">
<nav class="sidebar">
<ul class="nav-groups">
<li class="nav-group-name">
<a href="../Extensions.html">Extensions</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a href="../Extensions/String.html">String</a>
</li>
<li class="nav-group-task">
<a href="../Extensions/UnicodeScalar.html">UnicodeScalar</a>
</li>
</ul>
</li>
</ul>
</nav>
<article class="main-content">
<section>
<section class="section">
<h1>String</h1>
<div class="declaration">
<div class="language">
<pre class="highlight"><code><span class="kd">struct</span> <span class="kt">String</span></code></pre>
</div>
</div>
</section>
<section class="section task-group-section">
<div class="task-group">
<ul>
<li class="item">
<div>
<code>
<a name="/s:vE10HTMLStringSS21addingUnicodeEntitiesSS"></a>
<a name="//apple_ref/swift/Property/addingUnicodeEntities" class="dashAnchor"></a>
<a class="token" href="#/s:vE10HTMLStringSS21addingUnicodeEntitiesSS">addingUnicodeEntities</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>Returns a new string made from the <code>String</code> by replacing every character
incompatible with HTML Unicode encoding (UTF-16 or UTF-8) by a decimal
HTML entity.</p>
<p><a href='#examples' class='anchor' aria-hidden=true><span class="header-anchor"></span></a><h3 id='examples'>Examples</h3></p>
<table><thead>
<tr>
<th>String</th>
<th>Result</th>
<th>Format</th>
</tr>
</thead><tbody>
<tr>
<td><code>&</code></td>
<td><code>&#38;</code></td>
<td>Decimal entity (part of the Unicode special characters)</td>
</tr>
<tr>
<td><code>Σ</code></td>
<td><code>Σ</code></td>
<td>Not escaped (Unicode compliant)</td>
</tr>
<tr>
<td><code>🇺🇸</code></td>
<td><code>🇺🇸</code></td>
<td>Not escaped (Unicode compliant)</td>
</tr>
<tr>
<td><code>a</code></td>
<td><code>a</code></td>
<td>Not escaped (alphanumerical)</td>
</tr>
</tbody></table>
<p><strong>Complexity</strong>: <code>O(N)</code> where <code>N</code> is the number of characters in the string.</p>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight"><code><span class="kd">public</span> <span class="k">var</span> <span class="nv">addingUnicodeEntities</span><span class="p">:</span> <span class="kt">String</span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/alexaubry/HTMLString/tree/3.0.0/Sources/HTMLString/HTMLString.swift#L24-L26">Show on GitHub</a>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/s:vE10HTMLStringSS19addingASCIIEntitiesSS"></a>
<a name="//apple_ref/swift/Property/addingASCIIEntities" class="dashAnchor"></a>
<a class="token" href="#/s:vE10HTMLStringSS19addingASCIIEntitiesSS">addingASCIIEntities</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>Returns a new string made from the <code>String</code> by replacing every character
incompatible with HTML ASCII encoding by a decimal HTML entity.</p>
<p><a href='#examples' class='anchor' aria-hidden=true><span class="header-anchor"></span></a><h3 id='examples'>Examples</h3></p>
<table><thead>
<tr>
<th>String</th>
<th>Result</th>
<th>Format</th>
</tr>
</thead><tbody>
<tr>
<td><code>&</code></td>
<td><code>&#38;</code></td>
<td>Decimal entity</td>
</tr>
<tr>
<td><code>Σ</code></td>
<td><code>&#931;</code></td>
<td>Decimal entity</td>
</tr>
<tr>
<td><code>🇺🇸</code></td>
<td><code>&#127482;&#127480;</code></td>
<td>Combined decimal entities (extented grapheme cluster)</td>
</tr>
<tr>
<td><code>a</code></td>
<td><code>a</code></td>
<td>Not escaped (alphanumerical)</td>
</tr>
</tbody></table>
<p><a href='#performance' class='anchor' aria-hidden=true><span class="header-anchor"></span></a><h3 id='performance'>Performance</h3></p>
<p>If your webpage is unicode encoded (UTF-16 or UTF-8) use <code>escapingForUnicodeHTML</code> instead
as it is faster, and produces less bloated and more readable HTML (as long as you are using
a unicode compliant HTML reader).</p>
<p><strong>Complexity</strong>: <code>O(N)</code> where <code>N</code> is the number of characters in the string.</p>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight"><code><span class="kd">public</span> <span class="k">var</span> <span class="nv">addingASCIIEntities</span><span class="p">:</span> <span class="kt">String</span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/alexaubry/HTMLString/tree/3.0.0/Sources/HTMLString/HTMLString.swift#L50-L52">Show on GitHub</a>
</div>
</section>
</div>
</li>
</ul>
</div>
<div class="task-group">
<ul>
<li class="item">
<div>
<code>
<a name="/s:vE10HTMLStringSS20removingHTMLEntitiesSS"></a>
<a name="//apple_ref/swift/Property/removingHTMLEntities" class="dashAnchor"></a>
<a class="token" href="#/s:vE10HTMLStringSS20removingHTMLEntitiesSS">removingHTMLEntities</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>Returns a new string made from the <code>String</code> by replacing every HTML entity
with the matching Unicode character.</p>
<p><a href='#examples' class='anchor' aria-hidden=true><span class="header-anchor"></span></a><h3 id='examples'>Examples</h3></p>
<table><thead>
<tr>
<th>String</th>
<th>Result</th>
<th>Format</th>
</tr>
</thead><tbody>
<tr>
<td><code>&amp;</code></td>
<td><code>&</code></td>
<td>Keyword entity</td>
</tr>
<tr>
<td><code>&#931;</code></td>
<td><code>Σ</code></td>
<td>Decimal entity</td>
</tr>
<tr>
<td><code>&#x10d;</code></td>
<td><code>č</code></td>
<td>Hexadecimal entity</td>
</tr>
<tr>
<td><code>&#127482;&#127480;</code></td>
<td><code>🇺🇸</code></td>
<td>Combined decimal entities (extented grapheme cluster)</td>
</tr>
<tr>
<td><code>a</code></td>
<td><code>a</code></td>
<td>Not an entity</td>
</tr>
<tr>
<td><code>&</code></td>
<td><code>&</code></td>
<td>Not an entity</td>
</tr>
</tbody></table>
<p><strong>Complexity</strong>: <code>O(N)</code> where <code>N</code> is the number of characters in the string.</p>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight"><code><span class="kd">public</span> <span class="k">var</span> <span class="nv">removingHTMLEntities</span><span class="p">:</span> <span class="kt">String</span></code></pre>
</div>
</div>
<div class="slightly-smaller">
<a href="https://github.com/alexaubry/HTMLString/tree/3.0.0/Sources/HTMLString/HTMLString.swift#L78-L135">Show on GitHub</a>
</div>
</section>
</div>
</li>
</ul>
</div>
</section>
</section>
<section id="footer">
<p>Copyright © 2016-2017 Alexis Aubry Radanovic. Licensed under the <a class="link" href="https://github.com/alexaubry/HTMLString/blob/master/LICENSE" target="_blank" rel="external">MIT License</a>.</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.7.3</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</article>
</div>
</body>
</div>
</html>