You need to sign in to do that
Don't have an account?
IceEngine
How to Change Charset in XML Document When in Outcall?
Hi,everyone!
I'm trying to send a http request to a Japanese app, which require the Shift_JIS charset.
so how to change the charset in the body, and also change here: <?xml version="1.0" encoding="Shift_JIS"?>
Any help would be much appreciated!
Thanks!
HttpRequest req= new HttpRequest();
req.setEndpoint('https://xxxxx');
req.setMethod('POST');
req.setHeader('content-type', 'text/xml; charset=Shift_JIS');
......
All Answers
If you are using xmlStreamWriter, you can set the encoding at the start of the document like this:
HttpRequest req= new HttpRequest();
req.setEndpoint('https://xxxxx');
req.setMethod('POST');
req.setHeader('content-type', 'text/xml; charset=Shift_JIS');
......
Thanks for reply,
when i try this, i would receive an error:
System.XmlException: Underlying stream encoding 'UTF-8' and input paramter for writeStartDocument() method 'Shift_JIS' do not match.
i try UTF-16, the error is the same.
Thanks for reply,
it changes the Header to charset=Shift_JIS,
but the body is change too ?
for example, <Node>Text</Node>
it change the node part or the text part, or the whole body?
anther question is, if there is a String, how can i change it to Shift_JIS charset?
(i must change string to Shift_JIS and encode to base64, and post the base64 code)
Thanks!