gitea: Index | Files

package charset

import ""


Package Files



var UTF8BOM = []byte{'\xef', '\xbb', '\xbf'}

UTF8BOM is the utf-8 byte-order marker

func DetectEncoding Uses

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

DetectEncoding detect the encoding of content

func RemoveBOMIfPresent Uses

func RemoveBOMIfPresent(content []byte) []byte

RemoveBOMIfPresent removes a UTF-8 BOM from a []byte

func ToUTF8 Uses

func ToUTF8(content string) string

ToUTF8 converts content to UTF8 encoding and ignore error

func ToUTF8DropErrors Uses

func ToUTF8DropErrors(content []byte) []byte

ToUTF8DropErrors makes sure the return string is valid utf-8; attempts conversion if possible

func ToUTF8WithErr Uses

func ToUTF8WithErr(content []byte) (string, error)

ToUTF8WithErr converts content to UTF8 encoding

func ToUTF8WithFallback Uses

func ToUTF8WithFallback(content []byte) []byte

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

Package charset imports 9 packages (graph) and is imported by 13 packages. Updated 2020-10-08. Refresh now. Tools for package owners.