i facing trouble in translating portuguese characters part of field in xml string. using transform method , encoded iso-8859-1 , ended following error:
javax.xml.transform.transformerexception: com.sun.org.apache.xml.internal.utils.wrappedruntimeexception: invalid byte 2 of 3-byte utf-8 sequence. here code using.
string transformedmessage = ""; bytearrayinputstream bais = null; try { bais = new bytearrayinputstream( inputmessage.getbytes("iso-8859-1")); } catch (unsupportedencodingexception e) { // todo auto-generated catch block e.printstacktrace(); } streamsource xsltsource = new streamsource( new bytearrayinputstream(xslttemplate.getbytes())); streamsource source = new streamsource(bais,"iso-8859-1"); bytearrayoutputstream baos = new bytearrayoutputstream(); streamresult result = new streamresult(baos); transformerfactory factory = transformerfactory.newinstance(); transformer transformer = factory.newtransformer(xsltsource); transformer.transform(source, result); transformedmessage = baos.tostring(); return transformedmessage; inputmessage has name tag name "olá" (related hex decimals : 4f 6c e1), whcih in portuguese.
the same code working if send chinese , thai characters. can please me error?
heres sample xml using.
<?xml version="1.0" encoding="utf-8"?><transactionprocessor> <request> <messagedata> <messagetype>authorization</messagetype> <ipaddress>187.150.23.80</ipaddress> <issuedate>20150715</issuedate> <travelagencyname>sindicato olá</travelagencyname> <traveldate>20150716</traveldate> <issuingcarriercode>ij</issuingcarriercode> </transactiondata> </request> </transactionprocessor>
Comments
Post a Comment