html

package
v1.25.0 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2025 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
templateパッケージ(html/template)は、コードインジェクションに対して安全なHTML出力を生成するための データ駆動型テンプレートを実装します。
templateパッケージ(html/template)は、コードインジェクションに対して安全なHTML出力を生成するための データ駆動型テンプレートを実装します。

Jump to

Keyboard shortcuts

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