javaapache-poixwpf

UTF-8 export with xwpf inconsistent


I'm doing template-edition with XWPF apache's POI lib on Office 2013. I'm using IntelIJ IDE.

When I'm doing my tests and run program in the IDE environment, everything works great: template is well encoded. But when I export the jar, everything works well too, but all accents are destroyed.

I have been seeking around my project, and it's not about the template nor the content data, but during the exportation. Has someone seen it before? What should I do?

Note: I've tested with Eclipse and I have the same problem, it's not an IDE configuration problem nor a build one.

There is not so much code I can show you: there is nothing really relevant for this problem. I'm using this method to export the .docx: POIXMLDocument#write(OutputStream)

Thanks for the help.

I tried to use that method (Encoding issue with Apache POI), on every text replacement but it doesn't seem to work.


Solution

  • Ok sorry, i've found a solution on this question Encoding issue with apache poi converter.

    Apparantly, you have to do this : String theNewString = URLDecoder.decode(URLEncoder.encode(new String(oldString.getBytes(), StandardCharsets.UTF_8), "UTF-8"), "UTF-8").

    Have a good day.