Save xml in default charset, but need utf-8.
to configuration i write russian text.
my code:
XMLFileHandler handler = new
XMLFileHandler(fileConfiguration.getAbsolutePath());
handler.setEncoding("UTF-8");
handler.store(configuration);
after save file, i try load him:
org.jconfig.ConfigurationManagerException: The parser
cannot parse the file: Invalid byte 2 of 2-byte UTF-8
sequence.
at org.jconfig.handler.XMLFileHandler.
load(XMLFileHandler.java:115)
at org.jconfig.handler.XMLFileHandler.
load(XMLFileHandler.java:69)
Logged In: YES
user_id=355897
Please try to use configuration.setEncoding("UTF-8") instead
of setting the encoding for the handler. This should work.
At least it worked for me.
Logged In: YES
user_id=317423
Did the last comment help solve the problem? If yes, then we
can close this bug/issue.
Thanks for any info.
No, the problem is still there, at least under Microsoft Windows. If I store a German umlaut like ä, ö, ü or ß, the file is corrupted using the XMLFileHandler.store() method. You can double check with Notepad++, etc. This file cannot be loaded, I get:
Uncaught exception occured at Tue Apr 06 16:03:50 CEST 2021:
org.jconfig.ConfigurationManagerException: The parser cannot parse the file: Invalid byte 2 of 3-byte UTF-8 sequence.
at org.jconfig.handler.XMLFileHandler.load(XMLFileHandler.java:122)
at org.jconfig.handler.XMLFileHandler.load(XMLFileHandler.java:78)
Under Linux the config file is written correctly including German umlauts. Doesn't matter if you use set the handler encoding, the configuration encoding or both to "UTF-8" or none of them.