...

Package charset

import "github.com/gabriel-vasile/mimetype/internal/charset"
Overview
Index

Overview ▾

Constants

const (
    F = 0 /* character never appears in text */
    T = 1 /* character appears in plain ASCII text */
    I = 2 /* character appears in ISO-8859 text */
    X = 3 /* character appears in non-ISO extended ASCII (Mac, IBM PC) */
)

func FromBOM

func FromBOM(content []byte) string

FromBOM returns the charset declared in the BOM of content.

func FromHTML

func FromHTML(content []byte) string

FromHTML returns the charset of an HTML document. It first looks if a BOM is present and if so uses it to determine the charset. If no BOM is present, it relies on the meta tag <meta charset="UTF-8"> and falls back on the plain text content.

func FromPlain

func FromPlain(content []byte) string

FromPlain returns the charset of a plain text. It relies on BOM presence and it falls back on checking each byte in content.

func FromXML

func FromXML(content []byte) string

FromXML returns the charset of an XML document. It relies on the XML header <?xml version="1.0" encoding="UTF-8"?> and falls back on the plain text content.