无法用MS Word文件中的Apache POI替换阿拉伯字符

fat*_*Dev 5 ms-word arabic apache-poi

我需要使用数据库中的值或用户输入的值动态修改Word文件.值和文件是阿拉伯语.

问题是它不能一直工作.每次,我都会遇到阿拉伯字符的新问题.

我正在使用的代码:

        FileInputStream in = new FileInputStream(path+"\\fiches\\"+fileName.trim()+".doc");
        POIFSFileSystem fs = new POIFSFileSystem(in);
        HWPFDocument doc = new HWPFDocument(fs);
        Range  r = doc.getRange();
         r.replaceText("<matricule>","  "+agent.getMatriculeAgent());
        r.replaceText("<cin>","  "+agent.getCin());
        r.replaceText("<????? ??????>", " "+agent.getPrenomAgentArabe());
        OutputStream out = response.getOutputStream();
        response.setContentType("application/rtf");
        response.setHeader("Content-Disposition","attachment; filename="+fileName);
        doc.write(out);
        out.flush();
Run Code Online (Sandbox Code Playgroud)

fat*_*Dev 0

不幸的是,这不是 POI 问题,问题的根源是我使用的模板,我发现文本区域或某些单词功能可能会导致此问题,模板必须是最简单的,例如:插入文本区域中的单词一个表可能会产生奇怪的行为或者不被替换,