CharsetDetector增加默认识别的长度

This commit is contained in:
Looly
2022-09-26 22:52:13 +08:00
parent bef38c365b
commit 52496bb62f
3 changed files with 12 additions and 2 deletions
+2 -1
View File
@@ -3,7 +3,7 @@
-------------------------------------------------------------------------------------------------------------
# 5.8.8.M1 (2022-09-26)
# 5.8.8 (2022-09-26)
### 🐣新特性
* 【core 】 StreamUtil.of方法新增对 Iterator 支持;StreamUtil.of(Iterable) 方法优化(pr#807@Gitee)
@@ -12,6 +12,7 @@
* 【core 】 ModifierUtil和ReflectUtil增加removeFinalModify(pr#810@Gitee)
* 【core 】 AbsCollValueMap添加removeValue和removeValues方法,用于list value值移除(pr#813@Gitee)
* 【extra 】 hutool-extra ftp 支持上传文件或目录(pr#821@Gitee)
* 【core 】 CharsetDetector增加默认识别的长度(issue#2547@Github)
### 🐞Bug修复
* 【core 】 修复FileNameUtil.cleanInvalid无法去除换行符问题(issue#I5RMZV@Gitee)
@@ -60,7 +60,7 @@ public class CharsetDetector {
* @return 编码
*/
public static Charset detect(InputStream in, Charset... charsets) {
return detect(IoUtil.DEFAULT_BUFFER_SIZE, in, charsets);
return detect(IoUtil.DEFAULT_LARGE_BUFFER_SIZE, in, charsets);
}
/**
@@ -3,6 +3,7 @@ package cn.hutool.core.io;
import cn.hutool.core.io.resource.ResourceUtil;
import cn.hutool.core.util.CharsetUtil;
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
import java.nio.charset.Charset;
@@ -16,4 +17,12 @@ public class CharsetDetectorTest {
CharsetUtil.CHARSET_GBK, CharsetUtil.CHARSET_UTF_8);
Assert.assertEquals(CharsetUtil.CHARSET_UTF_8, detect);
}
@Test
@Ignore
public void issue2547() {
final Charset detect = CharsetDetector.detect(IoUtil.DEFAULT_LARGE_BUFFER_SIZE,
ResourceUtil.getStream("d:/test/default.txt"));
Assert.assertEquals(CharsetUtil.CHARSET_UTF_8, detect);
}
}