xstr

package
v0.0.0-...-26e1b9e Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GBK     string = "GBK"
	UTF8    string = "UTF8"
	UNKNOWN string = "UNKNOWN"
)

Variables

This section is empty.

Functions

func ContainSubsAny

func ContainSubsAny(str string, subs ...string) (result bool)

func EncodeWithGBK

func EncodeWithGBK(src string) (dst string, err error)

EncodeWithGBK 目前只能把UTF8转为GBK,若字符串为GBK则原样输出

func EncodeWithUTF8

func EncodeWithUTF8(src string) (dst string, err error)

EncodeWithUTF8 目前只能把GBK转为UTF8,若字符串为UTF8则原样输出

func GetRandomString

func GetRandomString(n int) string

GetRandomString 生成随机字符串

func GetStrCoding

func GetStrCoding(data []byte) string

需要说明的是,isGBK()是通过双字节是否落在gbk的编码范围内实现的, 而utf-8编码格式的每个字节都是落在gbk的编码范围内, 所以只有先调用isUtf8()先判断不是utf-8编码,再调用isGBK()才有意义

func IsChinese

func IsChinese(str string) bool

IsChinese 如果输入的字符串都是中文,则为true 用于校验传入的字符串是不是姓名等汉字

func ParseInt64

func ParseInt64(b string, defInt int64) int64

ParseInt64 string转换int

func StrToUInt64

func StrToUInt64(str string) uint64

StrToUInt64 字符串

Types

This section is empty.

Jump to

Keyboard shortcuts

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