$resp = Invoke-WebRequest -Uri ...$html=[system.Text.Encoding]::UTF8.GetString($resp.RawContentStream.ToArray());I'm using Invoke-RestMethod to get page names from an application I'm using. I notice that when I do a GET on the page it returns the page name like soHowever the actual page name isHere's how my request looks Invoke-WebRequest -Uri ("https://example.com/rest/api/content/123789") -Method Get -Headers $Credentials -ContentType "application/json; charset=utf-8"The problem is with the en-dash, does anyone know how I can fix this? 解决方案 In case of Invoke-WebRequest does not detect responce encoding right, you can use RawContentStream and convert it to needed encoding:$resp = Invoke-WebRequest -Uri ... $html=[system.Text.Encoding]::UTF8.GetString($resp.RawContentStream.ToArray()); 这篇关于Powershell Invoke-RestMethod 不正确的字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
09-05 18:35
查看更多