Documentation
¶
Index ¶
- Variables
- func AllowRuneNBSP() map[rune]bool
- func DetectEncoding(content []byte) (encoding string, _ error)
- func ToUTF8(content []byte, opts ConvertOpts) []byte
- func ToUTF8DropErrors(content []byte) []byte
- func ToUTF8WithFallback(content []byte, opts ConvertOpts) []byte
- func ToUTF8WithFallbackReader(rd io.Reader, opts ConvertOpts) io.Reader
- type AmbiguousTable
- type ConvertOpts
- type EscapeOptions
- type EscapeStatus
Constants ¶
This section is empty.
Variables ¶
var ToUTF8WithFallbackReaderPrefetchSize = 16 * 1024
Functions ¶
func AllowRuneNBSP ¶ added in v1.26.0
func DetectEncoding ¶
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 ToUTF8WithFallback ¶
func ToUTF8WithFallback(content []byte, opts ConvertOpts) []byte
ToUTF8WithFallback detects the encoding of content and converts to UTF-8 if possible
func ToUTF8WithFallbackReader ¶ added in v1.15.0
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 ¶ added in v1.17.4
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 ¶ added in v1.17.4
func AmbiguousTablesForLocale(locale translation.Locale) []*AmbiguousTable
AmbiguousTablesForLocale provides the table of ambiguous characters for this locale.
type ConvertOpts ¶ added in v1.21.5
type EscapeOptions ¶ added in v1.26.0
func EscapeOptionsForView ¶ added in v1.26.0
func EscapeOptionsForView() EscapeOptions
type EscapeStatus ¶ added in v1.16.0
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 ¶ added in v1.17.4
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 ¶ added in v1.16.0
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 ¶ added in v1.16.0
func (status *EscapeStatus) Or(other *EscapeStatus) *EscapeStatus
Or combines two EscapeStatus structs into one representing the conjunction of the two