2

I'm invoking web services to retrieve XML data. I save response to xml variable:

$Response = Invoke-WebRequest $newURL -Method Post -Headers @{SOAPAction=$newURL} -ContentType "text/xml" -Body $queryBody

Result of the web service is xml with UTF-8 encoding in the header section.

However when I access some elements i.e. like this:

$response.Envelope.Body.describeSObjectResponse.result.fields[4].picklistValues

I can see that some values are converted to ascii because some national characters are replaced with character "?".

Could you please advise how can I read these elements in UTF-8 encoding?

EDIT 1.3.2014:
Seems like the problem is with the Invoke-WebRequest. If I redirect output with -outfile switch to file, the encoding in the file is correct. If I then load content of the xml file into xml variable encoding is still correct.

Any ideas, how I can achieve the same but without redirecting the output to the file; i.e. working directly inside powershell logic?

2
  • What font are you using in the PowerShell host? The default font in the regular console host (the same one command prompt uses), Terminal, doesn't support UTF-8. Commented Mar 1, 2014 at 0:09
  • I'm executing script in Windows PowerShell ISE and font is: Lucida Console 9pt Commented Mar 1, 2014 at 0:17

1 Answer 1

1

It looks like you may be running into a bug with this command. If this Connect issue looks what you're seeing, be sure to vote on it.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.