Documentation ¶
Index ¶
- Constants
- func DecodeBytes(encoding encoding.Encoding, bs []byte) ([]byte, error)
- func DecodeString(encoding encoding.Encoding, s string) (string, error)
- func EncodeBytes(encoding encoding.Encoding, bs []byte) ([]byte, error)
- func EncodeString(encoding encoding.Encoding, s string) (string, error)
- func GetEncoding(iana string) (encode encoding.Encoding, exist bool)
- type DetectResult
Constants ¶
View Source
const ( IANA_UTF8 = "UTF-8" // * IANA_UTF16BE = "UTF-16BE" // * IANA_UTF16LE = "UTF-16LE" // * IANA_UTF32BE = "UTF-32BE" // * IANA_UTF32LE = "UTF-32LE" // * IANA_ISO8859_1 = "ISO-8859-1" // en, da, de, es, fr, it, nl, no, pt, sv IANA_ISO8859_2 = "ISO-8859-2" // cs, hu, pl, ro IANA_ISO8859_5 = "ISO-8859-5" // ru IANA_ISO8859_6 = "ISO-8859-6" // ar IANA_ISO8859_7 = "ISO-8859-7" // el IANA_ISO8859_8 = "ISO-8859-8" // he IANA_ISO8859_8I = "ISO-8859-8-I" // he IANA_ISO8859_9 = "ISO-8859-9" // tr IANA_KOI8R = "KOI8-R" // ru IANA_WINDOWS1251 = "windows-1251" // ar IANA_WINDOWS1256 = "windows-1256" // ar IANA_IBM424RTL = "IBM424_rtl" // he IANA_IBM424LTR = "IBM424_ltr" // he IANA_IBM420RTL = "IBM420_rtl" // ar IANA_IBM420LTR = "IBM420_ltr" // ar IANA_SHIFTJIS = "Shift_JIS" // ja IANA_GBK = "GBK" // zh IANA_GB18030 = "GB18030" // zh IANA_BIG5 = "Big5" // zh IANA_EUCJP = "EUC-JP" // ja IANA_EUCKR = "EUC-KR" // ko IANA_ISO2022JP = "ISO-2022-JP" // jp IANA_ISO2022KR = "ISO-2022-KR" // kr IANA_ISO2022CN = "ISO-2022-CN" // cn )
See https://github.com/saintfish/chardet/blob/master/detector.go and https://www.iana.org/assignments/charset-reg/charset-reg.xhtml.
Variables ¶
This section is empty.
Functions ¶
func DecodeBytes ¶
DecodeBytes decodes a bytes to given encoding.
func DecodeString ¶
DecodeString decodes a string to given encoding.
func EncodeBytes ¶
EncodeBytes encodes a bytes to given encoding.
func EncodeString ¶
EncodeString encodes a string to given encoding.
Types ¶
type DetectResult ¶
type DetectResult struct { // Charset represents IANA or MIME name of the detected charset. Charset string // Language represents IANA name of the detected language. It may be empty for some charsets. Language string // Confidence represents the confidence of the result. Scale from 1 to 100. Confidence int }
DetectResult contains the information for charset detector. See chardet.Result.
func DetectAllCharsets ¶ added in v1.5.0
func DetectAllCharsets(bs []byte) ([]*DetectResult, bool)
DetectAllCharsets detects bytes and returns all charsets in confidence's descending order.
func DetectBestCharset ¶ added in v1.5.0
func DetectBestCharset(bs []byte) (*DetectResult, bool)
DetectBestCharset detects bytes and returns the charset result with highest confidence.
Click to show internal directories.
Click to hide internal directories.