While working with XML, XML encoding is a pretty major problem that we face. Various vanilla BS which we use working with XML fail if we don’t have right encoding of the XML.
Transcode BS is the one which can help us in this type of situation. We can use convert method of Transcode Service to convert from one type of encoding to another. But another problem that I have seen when we use this business service is
I used Transcode Service’s “Convert” method to convert from UTF-8 to UTF-16. Even though encoding got changed but XML header
<?xml version=”1.0″ encoding=”UTF-8″ ?>
still contains old encoding type i.e UTF-8 which means that vanilla BS are still going to fail.
There is a workaround that we can use to overcome this problem.
Use Transcode BS and then change the header manually (by manually I mean through script) to reflect correct encoding. Here is a sample code below provided to me by my friend Jeevan Singh which can help you to achieve that.
function ChangeHeader(Inputs, Outputs)
var inXML = Inputs.GetProperty(“InputXML”);
var outXML = inXML.substring(0,34) + “16” + inXML.substring(35);
Hope this helps