Invoke-WebRequest does not support UTF-8 (СКУД) #5528
文章推薦指數: 80 %
Invoke-WebRequest does not support UTF-8 (СКУД) #5528 ... Content -Path c:\temp\export.txt -Encoding UTF8 -force ... Skiptocontent {{message}} PowerShell / PowerShell Public Notifications Fork 5.9k Star 35.3k Code Issues 3.2k Pullrequests 88 Discussions Actions Projects 14 Security Insights More Code Issues Pullrequests Discussions Actions Projects Security Insights Newissue Haveaquestionaboutthisproject?SignupforafreeGitHubaccounttoopenanissueandcontactitsmaintainersandthecommunity. Pickausername EmailAddress Password SignupforGitHub Byclicking“SignupforGitHub”,youagreetoourtermsofserviceand privacystatement.We’lloccasionallysendyouaccountrelatedemails. AlreadyonGitHub? Signin toyouraccount Jumptobottom Invoke-WebRequestdoesnotsupportUTF-8(СКУД) #5528 Closed lipkauopenedthisissue Nov22,2017 ·5comments Closed Invoke-WebRequestdoesnotsupportUTF-8(СКУД) #5528 lipkauopenedthisissue Nov22,2017 ·5comments Labels Issue-Question ideallysupportcanbeprovidedviaothermechanisms,butsometimesfolksdoopenanissuetogeta Resolution-Answered Thequestionisanswered. WG-Cmdlets-Utility cmdletsintheMicrosoft.PowerShell.Utilitymodule Comments Copylink lipkau commented Nov22,2017 • edited @##Stepstoreproduce AssumingyouhaveaURIthatreturnsjsonandcontainsanon-Latinchar MysampleisaConfluencewikipagewhichIamrequestingwithREST $splatParameters=@{ Uri="https://powershell.atlassian.net/wiki/rest/api/content/13009245?expand=space,version,body.storage,ancestors&limit=25" Method="GET" Headers=@{ "Accept-Charset"="utf-8" "Accept"="application/json" "Content-Type"="application/json;charset=utf-8" "Authorization"="Basicabcd" } UseBasicParsing=$true ErrorAction='SilentlyContinue' }; Set-Content-Value(Invoke-WebRequest@splatParameters).Content-Pathc:\temp\export.txt-EncodingUTF8-force Expectedbehavior Invoke-WebRequestisabletowritethefilewithfullsupportoftheunicodecharsofthesource. Inthisexample:СхемаСКУД Actualbehavior TheRESTcallshouldreturnajsonlikethis: {"id":"13009245","type":"page","status":"current","title":"СхемаСКУД","space":{.... instead,thecontentofc:\temp\export.txt(seeexampleebove)contains: {"id":"13009245","type":"page","status":"current","title":"СÑ�емаСÐ�УÐ�","space":{..... Environmentdata PSC:\ProgramFiles\PowerShell\6.0.0-rc>$PSVersiontable NameValue --------- PSVersion6.0.0-rc PSEditionCore GitCommitIdv6.0.0-rc OSMicrosoftWindows10.0.15063 PlatformWin32NT PSCompatibleVersions{1.0,2.0,3.0,4.0...} PSRemotingProtocolVersion2.3 SerializationVersion1.1.0.1 WSManStackVersion3.0 Thetextwasupdatedsuccessfully,buttheseerrorswereencountered: Allreactions lipkau mentionedthisissue Nov22,2017 Textencodingproblems AtlassianPS/ConfluencePS#101 Closed Copylink Contributor markekraus commented Nov22,2017 @lipkauHaveyoureproducedthisissuein6.0.0-rc?ThisrepositoryisforPowerShellCoreissues.ifyouhaveanissuewithWindowsPowerShell5.1,pleaseusetheUserVoice. Allreactions Sorry,somethingwentwrong. markekraus added WG-Cmdlets-Utility cmdletsintheMicrosoft.PowerShell.Utilitymodule Issue-Question ideallysupportcanbeprovidedviaothermechanisms,butsometimesfolksdoopenanissuetogeta labels Nov22,2017 Copylink Author lipkau commented Nov22,2017 Yes...Iamwaitingon@Jaykulforthe$PSVersionTable(hetesteditforme) Allreactions Sorry,somethingwentwrong. Copylink Author lipkau commented Nov22,2017 VersionTableupdated Allreactions Sorry,somethingwentwrong. Copylink Contributor markekraus commented Nov22,2017 Sincethisissuehassomenon-latincharactersinitandisaccessibleviaanAPIthatreturnsapplication/jsonthefollowingshouldbeanequivalentrepro: $response=Invoke-WebRequest'https://api.github.com/repos/PowerShell/PowerShell/issues/5528' Set-Content-Value$response.Content-Pathc:\temp\export.txt-EncodingUTF8-force WhenIdothat,IseeСхемаСКУДinthefile. Areyousurethat1)theAPIyouareworkingwithisactuallyreturningUTF8encodingand2)thebodyofthatcontentisactuallyencodedinutf8? $response.BaseResponse.Content.Headers.ContentType.CharSet Allreactions Sorry,somethingwentwrong. Copylink Author lipkau commented Nov22,2017 ThisseemstobeaConfluenceAPIproblem. Closingthisissue. Allreactions Sorry,somethingwentwrong. lipkau closedthisascompleted Nov22,2017 lipkau changedthetitle Invoke-WebRequestdoesnotsupportUTF-8 Invoke-WebRequestdoesnotsupportUTF-8(СКУД) Nov22,2017 Jaykul mentionedthisissue Nov22,2017 WebCmdletsshouldreadtheencodingofContent-Typeapplication/jsonperRFC #5530 Closed iSazonov added the Resolution-Answered Thequestionisanswered. label Dec1,2017 Signupforfree tojointhisconversationonGitHub. Alreadyhaveanaccount? Signintocomment Assignees Nooneassigned Labels Issue-Question ideallysupportcanbeprovidedviaothermechanisms,butsometimesfolksdoopenanissuetogeta Resolution-Answered Thequestionisanswered. WG-Cmdlets-Utility cmdletsintheMicrosoft.PowerShell.Utilitymodule Projects Noneyet Milestone Nomilestone Development Nobranchesorpullrequests 3participants Youcan’tperformthatactionatthistime. Yousignedinwithanothertaborwindow.Reloadtorefreshyoursession. Yousignedoutinanothertaborwindow.Reloadtorefreshyoursession.
延伸文章資訊
- 1Invoke-Webrequest Encoding - TechNet - Microsoft
When i use Invoke-WebRequest or Invoke-RestMethod the ÆØÅ are not formatted ... charset=utf-8" } ...
- 2Powershell encoding - Ivanti Community
However I had to adjust to UTF-8 for some PUT/POST messages like bellow (to have Emoji in push no...
- 3Wrong encoding on PowerShell Invoke-WebRequest POST
... ďábelské ódy" Invoke-WebRequest -Uri 'http://www.example.com/' -Method Post -Body $postData -...
- 4Special Characters utf8-bom with the API - Meraki Community
Special Characters utf8-bom with the API ... Encoding]::UTF8. ... $change = Invoke-RestMethod -Me...
- 5I need some help with a text encoding issue with Invoke ...
#get the latest alerts [xml]$alertInfo = Invoke-RestMethod -Uri ... to try and convert the text i...