Skip to content

Instantly share code, notes, and snippets.

@missdeer
Created September 1, 2014 03:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save missdeer/54570737b21a11e124c6 to your computer and use it in GitHub Desktop.
Save missdeer/54570737b21a11e124c6 to your computer and use it in GitHub Desktop.
unmarshal non-utf8 xml
import "code.google.com/p/go.net/html/charset"
ad := &models.ArticleDocument{}
d := xml.NewDecoder(bytes.NewReader([]byte(xmldoc)))
d.CharsetReader = func(s string, r io.Reader) (io.Reader, error) {
return charset.NewReader(r, s)
}
d.Decode(ad)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment