charsetKit

package
v3.0.910 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Convert 转换字符串的编码(字符集的编码)
	/*
	   支持的字符集(charset): UTF-8、GBK、Big5、ISO-* 等,更多详见: https://goframe.org/pages/viewpage.action?pageId=1114178.
	*/
	Convert func(dstCharset string, srcCharset string, src string) (dst string, err error) = gcharset.Convert

	ToUTF8 func(srcCharset string, src string) (dst string, err error) = gcharset.ToUTF8

	UTF8To func(dstCharset string, src string) (dst string, err error) = gcharset.UTF8To
)
View Source
var DetermineEncoding func(content []byte, contentType string) (e encoding.Encoding, name string, certain bool) = charset.DetermineEncoding

DetermineEncoding 编码推断.

Deprecated: 不一定准(检测GBK文本有问题,推断出来的是 "windows-1252").

View Source
var IsSupported func(charset string) bool = gcharset.Supported

IsSupported 是否支持 指定字符集 ?

View Source
var IsUTF8 func(data []byte) bool = utf8.Valid
View Source
var IsUTF8String func(s string) bool = utf8.ValidString

Functions

func Detect deprecated

func Detect(data []byte) (charset string, err error)

Detect 检测文本的编码.

Deprecated: 不一定准(检测GBK文本有问题,推断出来的是 "ISO-8859-1").

func IsGBK

func IsGBK(data []byte) bool

IsGBK

PS: 在Go语言中,你可以通过检查字节序列是否落在 GBK 编码范围内来判断文本编码是否为 GBK。

Types

This section is empty.

Jump to

Keyboard shortcuts

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