String
struct String
-
Global HTML escape options
See moreDeclaration
Swift
public struct HTMLEscapeOptions
-
Return string as HTML escaped by replacing non-ASCII and unsafe characters with their numeric character escapes, or if such exists, their HTML named character reference equivalents. For example, this function turns
"<script>alert("abc")</script>"
into
"<script>alert("abc")</script>"
You can view/change default option values globally via
String.HTMLEscapeOptions
.Declaration
Swift
public func htmlEscape(allowUnsafeSymbols: Bool = HTMLEscapeOptions.allowUnsafeSymbols, decimal: Bool = HTMLEscapeOptions.decimal, encodeEverything: Bool = HTMLEscapeOptions.encodeEverything, useNamedReferences: Bool = HTMLEscapeOptions.useNamedReferences) -> String
-
Return string as HTML unescaped by replacing HTML character references with their unicode character equivalents. For example, this function turns
"<script>alert("abc")</script>"
into
"<script>alert(\"abc\")</script>"
Declaration
Swift
public func htmlUnescape(strict: Bool) throws -> String
-
Return string as HTML unescaped by replacing HTML character references with their unicode character equivalents. For example, this function turns
"<script>alert("abc")</script>"
into
"<script>alert(\"abc\")</script>"
Equivalent to
htmlUnescape(strict: false)
, but does NOT throw parse error.Declaration
Swift
public func htmlUnescape() -> String