Wrong encoding from - Invoke-WebRequest - SAPIEN Forums

文章推薦指數: 80 %
投票人數:10人

but when I get the data, it is not in the right encoding, it should be UTF8 but it is not when Invoke-WebRequest have been handling it. SAPIENTechnologies Search Advancedsearch Support CommunityForums Quicklinks Unansweredtopics Activetopics Search Poststoplist Votelist CommunityForums ScriptingAnswers PowerShell Search Wrongencodingfrom-Invoke-WebRequest AskyourPowerShell-relatedquestions,includingquestionsoncmdletdevelopment! Forumrules Donotpostanylicensinginformationinthisforum. Anycodelongerthanthreelinesshouldbeaddedascodeusingthe'SelectCode'dropdownmenuorattachedasafile. Locked Printview Search Advancedsearch 5posts •Page1of1 Kilsgaard Posts:21 Lastvisit:WedAug31,20222:48am Wrongencodingfrom-Invoke-WebRequest Post byKilsgaard»ThuNov04,20219:08am Hi Iamintheneedof,someserioushelp IamworkingonasmallPowerShellGUI,thatgetsdatafromacoupleofWEBservices.. butwhenIgetthedata,itisnotintherightencoding,itshouldbeUTF8butitisnotwhenInvoke-WebRequesthavebeenhandlingit. Icansethatthereisalotofpostsaboutthisontheinternet,butIhavenothadanysuccessfixingtheencodingontheUTF8datathatisgettingbackfromthewebservices.. CouldanyonehelpmewithanalternativewayofgettingthedataoranidearhowIfixthedatawheninvoke-webrequesthavedeliveredtheminabadformat. Ihavetriedwiththedifferentwayswithgetbytesandloops.. butitdoesnotfixmyencoding thanksonadwance /Graves Top jvierra Posts:15299 Lastvisit:MonOct10,202212:00pm Answers:26 Has voted:4times Been upvoted:29times Re:Wrongencodingfrom-Invoke-WebRequest Post byjvierra»ThuNov04,20214:12pm Youhavetoaccepttheencodingofthewebservice.Saveittoafileandconvertthefile. IWRreturnsanobjectthathastherawdataembedded.Differentwebservicesreturndifferentobjects.Theteztintheobjectpropertieswillbeasinsertedbythewebserviceandinthatencoding. Top jvierra Posts:15299 Lastvisit:MonOct10,202212:00pm Answers:26 Has voted:4times Been upvoted:29times Re:Wrongencodingfrom-Invoke-WebRequest Post byjvierra»ThuNov04,20214:18pm YouprobablywanttouseNew-WebServiceProxy.IWRisusedtograbwebpagesandnottocallawebservice. Top Kilsgaard Posts:21 Lastvisit:WedAug31,20222:48am Re:Wrongencodingfrom-Invoke-WebRequest Post byKilsgaard»ThuNov11,20217:14am Hi Thanksfortheidea's. Gotitworkingwritingafile,andreadingitagain.. Itwasthequickfix,butIwilltryworkwiththeNew-WebServiceProxywhenImodifymycode /Graves Top jvierra Posts:15299 Lastvisit:MonOct10,202212:00pm Answers:26 Has voted:4times Been upvoted:29times Re:Wrongencodingfrom-Invoke-WebRequest Post byjvierra»ThuNov11,20219:16am JUstnotethatwhatyougetbackfrom"Invoke-WebRequest"isanobjectandcannotbedisplayedastext.Ifyououtputtoafilethewebpageisconvertedtotextsoitwillbereadable.TheissueisasInotedabove,theobjectstextfromtheremoteserverdoesnothaveaBOMsoitwon'tconvertcorrectlybuttheInvoke-Commandhastehabilitytousetheobjecttodetecttheencodingandconvertitcorrectlyinmostcases. Again,WebRequestisnotthecorrectcommandtouseforawebservice.Youwanttousethecorrectcommandandallofthisgoesaway.TheotherissueisthatyouhavenotgivenanyindicationofwhyyouareusinganHTMLbrowseremulatortoqueryawebservice.Mostoftheobjectisuselessandthe"contents"propertycontainsthewebserviceresponseasplaintextandinthecorrectencodingforPowerShell. Top Locked Printview Display:Allposts1day7days2weeks1month3months6months1year Sortby:AuthorPosttimeSubject Direction:AscendingDescending 5posts •Page1of1 Returnto“PowerShell” Jumpto CustomerServiceForums ↳ CustomerService ↳ FormerandFutureCustomers-Questions ↳ WishListandFeatureRequests ↳ InstallationIssues ↳ FreeTools ↳ Feedback ProductSupportForums ↳ PrimalScript ↳ PowerShellStudio ↳ VersionRecall ↳ PowerShellHelpWriter ↳ PowerShellModuleManager ↳ CIMExplorer ↳ PrimalSQL ↳ PrimalXML ↳ iPowerShell ↳ ProductivityPackSupport ScriptingAnswers ↳ PowerShell ↳ PowerShellGUIs ↳ VBScript ↳ OtherScriptingLanguages ↳ PrimalForms ↳ ChangeVue CommunityForums AlltimesareUTC-07:00 Deletecookies Contactus    



請為這篇文章評分?