Powershell:如何转换;国际标准化组织;字符到UTF8?

Powershell:如何转换;国际标准化组织;字符到UTF8?,powershell,encoding,utf-8,Powershell,Encoding,Utf 8,我使用此功能下载一些RSS提要并将其写入Excel文件: 函数获取RSS{ 参数([string]$url) $Results=@() $wc=新对象Net.WebClient $wc.Encoding=[System.Text.Encoding]::UTF8 [xml]$resp=$wc.DownloadString(“$url”) $article=$resp.rss.channel.item foreach(在$article中){ [字符串]$description=$in.descri

我使用此功能下载一些RSS提要并将其写入Excel文件:

函数获取RSS{
参数([string]$url)
$Results=@()
$wc=新对象Net.WebClient
$wc.Encoding=[System.Text.Encoding]::UTF8
[xml]$resp=$wc.DownloadString(“$url”)
$article=$resp.rss.channel.item
foreach(在$article中){
[字符串]$description=$in.description.InnerText-替换“”
$Results+=Set News-Title$in.Title-Content$description-PublishDate$in.PublishDate-Link$in.OrigLink
}
返回$Results
}

下载工作正常,但我对以下特定字符有问题:

…; ’ ;


我在Excel中看到,如何将其转换为代码后面的字符?

您需要解码html字符。改变

[xml]$resp=$wc.DownloadString(“$url”)

[xml]$resp=[System.Web.HttpUtility]::HtmlDecode($wc.DownloadString($url)))
如果您使用的是PS2,请在脚本/函数顶部添加
add Type-AssemblyName System.Web
,以导入所需的.NET二进制文件