Help us shape the future of Go! Take the 2026 Go Developer Survey

charset

package
v1.27.3 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ToUTF8WithFallbackReaderPrefetchSize = 16 * 1024

Functions

func AllowRuneNBSP

func AllowRuneNBSP() map[rune]bool

func DetectEncoding

func DetectEncoding(content []byte) (encoding string, _ error)

DetectEncoding detect the encoding of content it always returns a detected or guessed "encoding" string, no matter error happens or not

func ToUTF8

func ToUTF8(content []byte, opts ConvertOpts) []byte

func ToUTF8DropErrors

func ToUTF8DropErrors(content []byte) []byte

func ToUTF8WithFallback

func ToUTF8WithFallback(content []byte, opts ConvertOpts) []byte

ToUTF8WithFallback detects the encoding of content and converts to UTF-8 if possible

func ToUTF8WithFallbackReader

func ToUTF8WithFallbackReader(rd io.Reader, opts ConvertOpts) io.Reader

ToUTF8WithFallbackReader detects the encoding of content and converts to UTF-8 reader if possible

Types

type AmbiguousTable

type AmbiguousTable struct {
	Confusable []rune
	With       []rune
	Locale     string
	RangeTable *unicode.RangeTable
}

AmbiguousTable matches a confusable rune with its partner for the Locale

func AmbiguousTablesForLocale

func AmbiguousTablesForLocale(locale translation.Locale) []*AmbiguousTable

AmbiguousTablesForLocale provides the table of ambiguous characters for this locale.

type ConvertOpts

type ConvertOpts struct {
	KeepBOM           bool
	ErrorReplacement  []byte
	ErrorReturnOrigin bool
}

type EscapeOptions

type EscapeOptions struct {
	Allowed map[rune]bool
}

func EscapeOptionsForView

func EscapeOptionsForView() EscapeOptions

type EscapeStatus

type EscapeStatus struct {
	Escaped      bool // it means that some characters were escaped, and they can also be unescaped back
	HasInvisible bool
	HasAmbiguous bool
}

EscapeStatus represents the findings of the Unicode escaper

func EscapeControlHTML

func EscapeControlHTML(html template.HTML, locale translation.Locale, opts ...EscapeOptions) (escaped *EscapeStatus, output template.HTML)

EscapeControlHTML escapes the Unicode control sequences in a provided html document

func EscapeControlReader

func EscapeControlReader(reader io.Reader, writer io.Writer, locale translation.Locale, opts ...EscapeOptions) (*EscapeStatus, error)

EscapeControlReader escapes the Unicode control sequences in a provided reader of HTML content and writer in a locale and returns the findings as an EscapeStatus

func (*EscapeStatus) Or

func (status *EscapeStatus) Or(other *EscapeStatus) *EscapeStatus

Or combines two EscapeStatus structs into one representing the conjunction of the two

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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