How do I encode UTF-8 using the XStream framework?

后端 未结 3 619
无人及你
无人及你 2020-12-13 15:53

Per XStream\'s FAQ its default parser does not preserve UTF-8 document encoding, and one must provide their own encoder. How does one do this?

Thanks!

3条回答
  •  无人及你
    2020-12-13 16:41

    Another solution would be to initiate the XStream-object with correct encoding, through a driver. Using the DomDriver this would look like:

    XStream xstream = new XStream(new DomDriver("UTF-8"));
    

    The (default) PrettyPrintWriter will be wrapped by an outputstream with correct encoding. You could not add the UTF-8 header this way however...

提交回复
热议问题