Go Standard Library Cookbook
上QQ阅读APP看书,第一时间看更新

Decoding a string from the non-Unicode charset

A lesser-known fact is that all content in .go files is encoded in UTF-8. Believe it or not the Unicode is not, the only charset in the world. For example, the Windows-1250 encoding is widely spread across Windows users.

When working with non-Unicode strings, you need to transcode the content to Unicode. This recipe demonstrates how to decode and encode the non-Unicode strings.