func main() { f, _ := os.Open("euckr.xml") defer f.Close() r, _ := cp949.NewReader(f) b := make([]byte, 10*1024) c, _ := r.Read(b) fmt.Println(c) fmt.Printf("%s", b[:c]) }
func unmarshalCp949XML(data []byte, v interface{}) error { d := xml.NewDecoder(bytes.NewBuffer(data)) d.CharsetReader = func(c string, i io.Reader) (io.Reader, error) { if c != "cp949" && c != "euc-kr" { return nil, errors.New("unexpect charset: " + c) } r, err := cp949.NewReader(i) if err != nil { return nil, err } return r, nil } return d.Decode(v) }