The easiest solution here is also probably the simplest one: have a factory method which returns the appropriate decoder/encoder based on the IANA code. The only work you need to do is to map the IANA codes to the corresponding charmaps. You can find a list of all the charmaps here. <pre class="lang-golang prettyprint-override">``` var codeToCharmap map[string]*charmap.Charmap func init() { codeToCharmap = map[string]*charmap.Charmap{ "windows-1250": charmap.Windows1250, "windows-1252": charmap.Windows1252, // ... } } func getDecoder(code string) *encoding.Decoder { if cm, ok := codeToCharmap[code]; ok { return cm.NewDecoder() } return nil } func getEncoder(code string) *encoding.Encoder { if cm, ok := codeToCharmap[code]; ok { return cm.NewEncoder() } return nil }