UTF 8 not working in live server

I am new to docx4j. I am creating new .docx file using docx4j. My code works perfectly while deploying project from eclipse to tomcat server. But it does not work on live server. Below is my code:

String html = "<html><head><meta charset=\"UTF-8\"><title></title>"
                + "</head><body>"
                + "<div><div style='width:100%;display:inline; text-align:right;'>मितिः &nbsp; "
                +new Date()+"</div><div class=\"block p-top-2\" style='display:block; float:left;'>"
                + "च.नं.  &nbsp;"
                + "<span style=\"display: inline !important;\">"+10088+" - "+73 + "/" + 74
                + "</span></div></div></body></html>";
WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.createPackage();

AlternativeFormatInputPart afiPart = new AlternativeFormatInputPart(new PartName("/hw.html"));
afiPart.setBinaryData(html.getBytes());
afiPart.setContentType(new ContentType("text/html"));
Relationship altChunkRel = wordMLPackage.getMainDocumentPart().addTargetPart(afiPart);
afiPart.registerInContentTypeManager(); 

CTAltChunk ac = Context.getWmlObjectFactory().createCTAltChunk();
ac.setId(altChunkRel.getId() );
wordMLPackage.getMainDocumentPart().addObject(ac);           

wordMLPackage.getContentTypeManager().addDefaultContentType("html", "text/html;charset=UTF-8");
wordMLPackage.save(new File("created_doc.docx"));

Below is my screen shot of my local: Expected format

Below is my screen shot of my live server UTF-8 not supported format

I am using Tomcat and Spring Framework.Project created using maven and deployed on windows server 2012 r2.

Jon Skeet
people
quotationmark

I suspect this may be the problem:

afiPart.setBinaryData(html.getBytes());

That will use the platform-default encoding - which could clearly differ between your local machine and your server. I would strongly encourage you to always specify the encoding. If you want UTF-8, use:

afiPart.setBinaryData(html.getBytes(StandardCharsets.UTF_8));

people

See more on this question at Stackoverflow