Documentation ¶
Index ¶
- Variables
- func DetectEncoding(content []byte) (string, error)
- func RemoveBOMIfPresent(content []byte) []byte
- func ToUTF8(content string) string
- func ToUTF8DropErrors(content []byte) []byte
- func ToUTF8WithErr(content []byte) (string, error)
- func ToUTF8WithFallback(content []byte) []byte
- func ToUTF8WithFallbackReader(rd io.Reader) io.Reader
- type EscapeStatus
Constants ¶
This section is empty.
Variables ¶
var UTF8BOM = []byte{'\xef', '\xbb', '\xbf'}
UTF8BOM is the utf-8 byte-order marker
Functions ¶
func DetectEncoding ¶
DetectEncoding detect the encoding of content
func RemoveBOMIfPresent ¶
RemoveBOMIfPresent removes a UTF-8 BOM from a []byte
func ToUTF8DropErrors ¶
ToUTF8DropErrors makes sure the return string is valid utf-8; attempts conversion if possible
func ToUTF8WithErr ¶
ToUTF8WithErr converts content to UTF8 encoding
func ToUTF8WithFallback ¶
ToUTF8WithFallback detects the encoding of content and coverts to UTF-8 if possible
Types ¶
type EscapeStatus ¶ added in v1.16.0
type EscapeStatus struct { Escaped bool HasError bool HasBadRunes bool HasControls bool HasSpaces bool HasMarks bool HasBIDI bool BadBIDI bool HasRTLScript bool HasLTRScript bool }
EscapeStatus represents the findings of the unicode escaper
func EscapeControlBytes ¶ added in v1.16.0
func EscapeControlBytes(text []byte) (EscapeStatus, []byte)
EscapeControlBytes escapes the unicode control sequences a provided []byte and returns the findings as an EscapeStatus and the escaped []byte
func EscapeControlReader ¶ added in v1.16.0
EscapeControlReader escapes the unicode control sequences a provided Reader writing the escaped output to the output and returns the findings as an EscapeStatus and an error
func EscapeControlString ¶ added in v1.16.0
func EscapeControlString(text string) (EscapeStatus, string)
EscapeControlString escapes the unicode control sequences in a provided string and returns the findings as an EscapeStatus and the escaped string
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