html

package
v1.21.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 31, 2023 License: MIT Imports: 0 Imported by: 0

Documentation

Overview

htmlパッケージは、HTMLテキストのエスケープとアンエスケープのための関数を提供します。

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func EscapeString

func EscapeString(s string) string

EscapeStringは、"<"のような特殊文字を"&lt;"にエスケープします。 それは、<, >, &, ' および " の5つの文字だけをエスケープします。 常にUnescapeString(EscapeString(s)) == sが成り立ちますが、その逆は 常に成り立つわけではありません。

Example
package main

import (
	"github.com/shogo82148/std/fmt"
	"github.com/shogo82148/std/html"
)

func main() {
	const s = `"Fran & Freddie's Diner" <tasty@example.com>`
	fmt.Println(html.EscapeString(s))
}
Output:

&#34;Fran &amp; Freddie&#39;s Diner&#34; &lt;tasty@example.com&gt;

func UnescapeString

func UnescapeString(s string) string

UnescapeStringは、"&lt;"のようなエンティティを"<"にアンエスケープします。 それはEscapeStringがエスケープするよりも広範なエンティティをアンエスケープします。 例えば、"&aacute;"は"á"に、"&#225;"も"&#xE1;"も"á"にアンエスケープします。 常にUnescapeString(EscapeString(s)) == sが成り立ちますが、その逆は 常に成り立つわけではありません。

Example
package main

import (
	"github.com/shogo82148/std/fmt"
	"github.com/shogo82148/std/html"
)

func main() {
	const s = `&quot;Fran &amp; Freddie&#39;s Diner&quot; &lt;tasty@example.com&gt;`
	fmt.Println(html.UnescapeString(s))
}
Output:

"Fran & Freddie's Diner" <tasty@example.com>

Types

This section is empty.

Directories

Path Synopsis
パッケージテンプレート(html/template)は、コードインジェクションに対して安全なHTML出力を生成するための データ駆動型テンプレートを実装します。
パッケージテンプレート(html/template)は、コードインジェクションに対して安全なHTML出力を生成するための データ駆動型テンプレートを実装します。

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL