From f05fea51a9e7edf2ff342869995b9cfd53da2439 Mon Sep 17 00:00:00 2001 From: HWliao <499606788@qq.com> Date: Mon, 25 Dec 2017 16:55:23 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=87=E6=9C=AC=E6=96=87=E4=BB=B6=E7=BC=96?= =?UTF-8?q?=E7=A0=81=E6=8E=A2=E6=B5=8B,=E4=BF=AE=E6=94=B9=20=E6=8E=A2?= =?UTF-8?q?=E6=B5=8B=E4=B8=8D=E5=88=B0=E7=BC=96=E7=A0=81=E4=B8=8D=E5=81=9A?= =?UTF-8?q?=E5=A4=84=E7=90=86=20=E6=96=87=E4=BB=B6=E5=86=85=E5=AE=B9?= =?UTF-8?q?=E8=BE=83=E5=B0=91=E6=97=B6,=E4=B8=80=E8=88=AC=E9=83=BD?= =?UTF-8?q?=E4=B8=8D=E5=87=86=E7=A1=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/yudianbank/utils/DownloadUtils.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/jodconverter-web/src/main/java/com/yudianbank/utils/DownloadUtils.java b/jodconverter-web/src/main/java/com/yudianbank/utils/DownloadUtils.java index 33b70c4e..c109d8f9 100644 --- a/jodconverter-web/src/main/java/com/yudianbank/utils/DownloadUtils.java +++ b/jodconverter-web/src/main/java/com/yudianbank/utils/DownloadUtils.java @@ -169,7 +169,9 @@ public class DownloadUtils { String encoding = null; try { FileCharsetDetector.Observer observer = FileCharsetDetector.guessFileEncoding(sourceFile); - encoding = observer.getEncoding(); + // 为准确探测到编码,不适用猜测的编码 + encoding = observer.isFound()?observer.getEncoding():null; + // 为准确探测到编码,可以考虑使用GBK 大部分文件都是windows系统产生的 } catch (IOException e) { // 编码探测失败, e.printStackTrace();