I have a simple java String object and wanna serialize/deserialize it, using XStream. Serialization works well, but as this string written, say, in russian, after deserialization I find out that encoding of the String broken.
Could anybody tell me if this problem of Xstream or problem of file and I need to write it in certain encoding.
Thanks everybody in advance!
I think it's because with the newer XStream version, you need to delegate the decoding to the Reader of you XML stream so that it's properly decoded using the right encoding scheme by the time it gets to the parsing.
Take a look at this, it might be helpful: http://x-stream.github.io/faq.html
Why does XStream not respect the encoding in the XML declaration?
XStream architecture is based on IO Readers and Writers, while the XML declaration is the responsibility of XML parsers. All HierarchicalStreamDriver implementations respect the encoding since version 1.3, but only if you provide an InputStream. If XStream consumes a Reader you have to initialize the reader with the appropriate encoding yourself, since it is now the reader's task to perform the encoding and no XML parser can change the encoding of a Reader and any encoding definition in the XML header will be ignored.