Skip to main content
Version: 2.8.x(Latest)

The GoFrame framework provides a powerful character encoding conversion module gcharset, supporting mutual conversion of common character sets.

Supported character sets:

EncodingCharacter Set
ChineseGBK/GB18030/GB2312/Big5
JapaneseEUCJP/ISO2022JP/ShiftJIS
KoreanEUCKR
UnicodeUTF-8/UTF-16/UTF-16BE/UTF-16LE
Other Encodingsmacintosh/IBM*/Windows*/ISO-*

Usage:

import "github.com/gogf/gf/v2/encoding/gcharset"

API Documentation:

https://pkg.go.dev/github.com/gogf/gf/v2/encoding/gcharset

Usage Example:

package main

import (
"fmt"

"github.com/gogf/gf/v2/encoding/gcharset"
)

func main() {
var (
src = "~{;(<dR;:x>F#,6@WCN^O`GW!#"
srcCharset = "GB2312"
dstCharset = "UTF-8"
)
str, err := gcharset.Convert(dstCharset, srcCharset, src)
if err != nil {
panic(err)
}
fmt.Println(str)
}

After execution, the terminal output is:

花间一壶酒,独酌无相亲。