U
U
un1t2015-11-24 18:29:05
go
un1t, 2015-11-24 18:29:05

How to parse xml with windows-1251 encoding?

I found this example
https://github.com/dps/go-xml-parse/blob/master/go...
It works if the file is in utf-8, with the appropriate header.
But if the file in windows-1251 does not work, it comes out in this place

t, _ := decoder.Token()
if t == nil {
    break
}

How to make it work?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
evnuh, 2015-11-24
@un1t

import (
    "encoding/xml"
    "golang.org/x/net/html/charset"
)

decoder := xml.NewDecoder(reader)
decoder.CharsetReader = charset.NewReaderLabel
err = decoder.Decode(&parsed)

Google helped me find the link stackoverflow.com/questions/6002619/unmarshal-an-i...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question