【发布时间】:2011-06-08 00:05:26
【问题描述】:
我正在解析来自http://toutankharton.com/ws/localisations.php?l=75的日期
如您所见,它已编码 (<name>Paris 2ème</name>)。
我的代码如下:
using (var reader = new StreamReader(stream, Encoding.UTF8))
{
var contents = reader.ReadToEnd();
XElement cities = XElement.Parse(contents);
var t = from city in cities.Descendants("city")
select new City
{
Name = city.Element("name").Value,
Insee = city.Element("ci").Value,
Code = city.Element("code").Value,
};
}
new StreamReader(stream, Encoding.UTF8) 还不够吗?
【问题讨论】:
-
你得到了什么意想不到的结果?读取为 UTF-8 似乎工作正常。
-
这座城市看起来像“巴黎二楼”