0

我需要帮助将字节数组转换为可以读取 € 符号的格式。现在,我正在处理的程序正在读取这样的文件:

new String(bytes, "ISO-8859-1")

我发现 ISO-8859-15 和 utf-8 可以使 € 可读。但是我找不到将数组转换为 ISO-8859-15 的方法。当我尝试使用 utf-8 时,我的字节数组没有被解码(它触发了一个循环)。字节数组来自另一个我无法修改甚至查阅代码的应用程序。

有没有办法显示€符号?有没有办法分析字节数组的内容,检测内容是否可转换?

if (truc) {

  // Initialisation d'une ressource odet API
  Resource gor = new Resource(...);
  PliPDFBean pdf = new PliPDFBean();
  byte[] flux = null;

  pdf=ImpressionNOE.recuperationFluxNOE(...);

  // Appel http
  int status = gor.webCall(pdf);

  // Recuperation du flux
  flux = gor.getResult();

  if (flux != null) {
    // longueur du byte et type de l'application
    response.setHeader("Content-Disposition", "attachment; filename=Reimpression.pdf");
    response.setContentLength(flux.length);
    response.setContentType("application/pdf");
    // ecrit les donnees dans le pdf
    
    try {
        String string_flux = new String(flux, "ISO-8859-1");
      response.getWriter().write(string_flux);  
    } catch (Exception e) {
        log.error("erreur ImpressionReedition"+ e.getMessage());
    }
    
  }

} 
4

0 回答 0