xml - Java: encoding changes from utf-8 to utf-16 -
i have function has return json jsp.
the information have return xml document.
the document has actualencoding = "utf-8" when convert string, utf-16.
any ideas?
here code:
document doc = null; doc = orgw3cdomutils.obtenerdocumentdebyte(bytes); objectwriter ow = new objectmapper().writer().withdefaultprettyprinter(); string json = ow.writevalueasstring(doc); jsresponse.getdata().put("respuesta", json);
and method obtenerdocumentdebyte gets document byte array:
public static document obtenerdocumentdebyte(byte[] documentoxml) throws exception { documentbuilderfactory factory = documentbuilderfactory.newinstance(); factory.setnamespaceaware(true); documentbuilder builder = factory.newdocumentbuilder(); return builder.parse(new bytearrayinputstream(documentoxml)); }
thanks in advance
Comments
Post a Comment