gcharset

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package gcharset 实现字符集转换功能。

支持的字符集:

中文: GBK/GB18030/GB2312/Big5 日语: EUCJP/ISO2022JP/ShiftJIS 韩语: EUCKR Unicode: UTF-8/UTF-16/UTF-16BE/UTF-16LE 其他: macintosh/IBM*/Windows*/ISO-*

Index

Constants

View Source
const MaxInputSize = 10 * 1024 * 1024 // 10MB

MaxInputSize 定义了允许处理的最大输入大小(例如:10MB)

Variables

View Source
var ErrUnsupportedCharset = errors.New("unsupported charset")

ErrUnsupportedCharset 表示不支持的字符集错误

Functions

func Convert

func Convert(dstCharset, srcCharset string, src string) (dst string, err error)

Convert 将src从srcCharset编码转换为dstCharset编码,并返回转换后的字符串 如果转换失败,则返回src作为dst

func ConvertWithSizeLimit

func ConvertWithSizeLimit(dstCharset, srcCharset string, src string) (dst string, err error)

ConvertWithSizeLimit 在进行转换之前检查输入大小,防止处理过大的输入

func Supported

func Supported(charset string) bool

Supported 返回是否支持指定的字符集

func ToUTF8

func ToUTF8(srcCharset string, src string) (dst string, err error)

ToUTF8 将src从srcCharset编码转换为UTF-8,并返回转换后的字符串

func UTF8To

func UTF8To(dstCharset string, src string) (dst string, err error)

UTF8To 将src从UTF-8编码转换为dstCharset,并返回转换后的字符串

Types

This section is empty.

Jump to

Keyboard shortcuts

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