O'Reilly logo

Go Standard Library Cookbook by Radomir Sohlich

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

How it works...

The package golang.org/x/text/encoding/charmap contains the Charset type for simple encoding and decoding. The type implements the NewDecoder method that creates the Decoder structure.

Steps 1 – 5 show the use of the decoding Reader.

The encoding works analogically. The encoding Writer is created and then each string written by this Writer is encoded into Windows-1250 encoding.

Note that the Windows-1250 was chosen as an example. The package, golang.org/x/text/encoding/charmap contains a lot of other charset options.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required