开发者

powershell character encoding from System.Net.WebClient

I am running the following command:

([xml](new-object net.webclient).DownloadString(
"http://blogs.msdn.com/powershell/rss.aspx"
)).rss.channel.item | format-table title,link

The output for one of开发者_开发技巧 the RSS items contains this weird text:

You Don’t Have to Be An Administrator to Run Remote PowerShell Commands

So, the question is:

  • Why the mix up in characters? What happened to the apostrophe? Why is the output rendered as Don’t when it should just render as Don't?
  • How would I get the correct character in the PowerShell standard output?


You need to set the encoding property of the webclient:

$wc = New-Object System.Net.WebClient
$wc.Encoding = [System.Text.Encoding]::UTF8
([xml]$wc.DownloadString( "http://blogs.msdn.com/powershell/rss.aspx" )).rss.channel.item | format-table title,link
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜