Skip to content

An easiest way to convert character set encodings in Go

License

Notifications You must be signed in to change notification settings

yuin/charsetutil

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

charsetutil - An easiest way to convert character set encodings in Go

charsetutil provides easiest way to convert character set encodings in Go.

Install

go get github.com/yuin/charsetutil

Utilities

  • Decode* : Converts from the specified charset to UTF-8.

  • Encode* : Converts from the UTF-8 to specified charset.

  • Guess* : Guesses a charcter set.

  • MustDecode* : Same as Decode*, but panics when errors occur

  • MustEncode* : Same as Encode*, but panics when errors occur

b, err = EncodeString("こんにちわ", "Windows-31J")
b, err = Encode("こんにちわ", "Windows-31J")
b, err = EncodeBytes([]byte("こんにちわ"), "Windows-31J")
b, err = EncodeReader(strings.NewReader("こんにちわ"), "Windows-31J")
b = MustEncodeString("こんにちわ", "Windows-31J")
b = MustEncode("こんにちわ", "Windows-31J")
b = MustEncodeBytes([]byte("こんにちわ"), "Windows-31J")
b = MustEncodeReader(strings.NewReader("こんにちわ"), "Windows-31J")

s, err = DecodeString(string(source), "Windows-31J")
s, err = Decode(source, "Windows-31J")
s, err = DecodeBytes(source, "Windows-31J")
s, err = DecodeReader(bytes.NewReader(source), "Windows-31J")
s = MustDecodeString(string(source), "Windows-31J")
s = MustDecode(source, "Windows-31J")
s = MustDecodeBytes(source, "Windows-31J")
s = MustDecodeReader(bytes.NewReader(source), "Windows-31J")

cs, err := GuessString(string(source))
cs, err := GuessBytes(source)
cs, err := GuessReader(bytes.NewReader(source))
cs, err := Guess(source)

Supported character sets

See Encoding spec on WHATWG

Author

Yusuke Inuzuka

License

BSD License

About

An easiest way to convert character set encodings in Go

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages