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:

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

    API Documentation:

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

    Usage Example:

    1. package main
    2. import (
    3. "fmt"
    4. "github.com/gogf/gf/v2/encoding/gcharset"
    5. )
    6. func main() {
    7. var (
    8. src = "~{;(<dR;:x>F#,6@WCN^O`GW!#"
    9. srcCharset = "GB2312"
    10. dstCharset = "UTF-8"
    11. )
    12. str, err := gcharset.Convert(dstCharset, srcCharset, src)
    13. if err != nil {
    14. panic(err)
    15. }
    16. fmt.Println(str)
    17. }

    After execution, the terminal output is:

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