在 Go 中解组 ISO-8859-1 XML 输入 [英] Unmarshal an ISO-8859-1 XML input in Go

查看:20
本文介绍了在 Go 中解组 ISO-8859-1 XML 输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当您的 XML 输入不是以 UTF-8 编码时,xml 包的 Unmarshal 函数似乎需要一个 CharsetReader.

When your XML input isn't encoded in UTF-8, the Unmarshal function of the xml package seems to require a CharsetReader.

你在哪里找到这样的东西?

Where do you find such a thing ?

推荐答案

更新了 2015 &超越:

import (
    "encoding/xml"
    "golang.org/x/net/html/charset"
)
reader := bytes.NewReader(theXml)
decoder := xml.NewDecoder(reader)
decoder.CharsetReader = charset.NewReaderLabel
err = decoder.Decode(&parsed)

这篇关于在 Go 中解组 ISO-8859-1 XML 输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆