wcu

package
v1.2.9 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2025 License: MIT Imports: 12 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CharsetFromContentType

func CharsetFromContentType(contentType string) string

func DecodeBytes

func DecodeBytes(src []byte, chatset string) ([]byte, error)

DecodeBytes Converts the bytes with specified charset to UTF-8.

func DetectAndDecodeBytes

func DetectAndDecodeBytes(src []byte, detect int, html ...bool) ([]byte, error)

DecodeBytes Detect the chatset of the bytes and convert it to UTF-8. detect: the maximum bytes to read for detect, if detect > 0 and detect < len(src).

func DetectAndOpenFile

func DetectAndOpenFile(filename string, detect int, charsets ...string) (io.ReadCloser, string, error)

DetectAndOpenFile use specified charsets to open file, return (transformed reader, encoding name, error). if charsets is not specified, or specified charset is unsupported, detect the charset of the file, and open a transformed ReadCloser. return (nil, "", err) if failed to open file, charset is unsupported or read error occurred.

func DetectAndReadFile

func DetectAndReadFile(filename string, detect int, charsets ...string) ([]byte, string, error)

DetectAndReadFile detect the charset of the file, and open a transformed ReadCloser

func DetectAndTransform

func DetectAndTransform(r io.Reader, detect int, html ...bool) (io.Reader, string, error)

DetectAndTransform Detect the chatset from the reader and transform the reader with the detected charset. detect: the maximum bytes to read for detect, if detect <= 0. otherwise read all `r` into buffer and return bytes.Reader.

func DetectCharsetBytes

func DetectCharsetBytes(data []byte, html ...bool) (string, error)

DetectCharsetBytes detect charset for the input byte array

func DetectCharsetFile

func DetectCharsetFile(filename string, limit int) (string, error)

DetectCharsetFile detect file's charset

func DetectCharsetReader

func DetectCharsetReader(r io.Reader, detect int, html ...bool) (io.Reader, string, error)

DetectCharsetReader detect charset for the input reader detect: the maximum bytes to read for detect, if detect <= 0. otherwise read all `r` into buffer and return bytes.Reader.

func IsHTMLFile

func IsHTMLFile(filename string) bool

func OpenFile

func OpenFile(filename string, charset string) (io.ReadCloser, error)

OpenFile use specified charset to open file and return a transformed ReadCloser. return (nil, error) if failed to open file or charset is unsupported

func ReadFile

func ReadFile(filename string, charset string) ([]byte, error)

ReadFile use specified charset to read file. return error if failed to open/read file or charset is unsupported

func Transform

func Transform(r io.Reader, charset string) (io.Reader, string, error)

Transform Transform the (transformed reader, encoding name, errorr) with the specified charset.

Types

This section is empty.

Jump to

Keyboard shortcuts

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