美文网首页
中文乱码问题解决

中文乱码问题解决

作者: 射手再见蓝天575 | 来源:发表于2019-02-22 14:25 被阅读0次

    这是使用Data-Processer生产数据过程中,字典中文部分生成乱码的问题

    对打印为乱码的字符串进行转义

    /**
    * 这是使用Data-Processer生产数据过程中,字典中文部分生成乱码的问题
    */
    DicInitializer.init();
    String tplName = "cara.dic";
    String tpl ="hello, My name is $Dic{name},My father is $Dic{father}";
    TemplateAnalyzer tmpAlz = new TemplateAnalyzer(tplName, tpl);
    // ------------重 点----------------
    //str 直接打印出现乱码
    String str = tmpAlz.analyse();
    //strOk 通过转义str 解决乱码
    String strOk=new String(str.getBytes("ISO-8859-1"),"UTF8");
    

    相关文章

      网友评论

          本文标题:中文乱码问题解决

          本文链接:https://www.haomeiwen.com/subject/mokeyqtx.html