Skip to content

Commit

Permalink
CharsetDetector增加默认识别的长度
Browse files Browse the repository at this point in the history
  • Loading branch information
looly committed Sep 26, 2022
1 parent bef38c3 commit 52496bb
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
Expand Up @@ -60,7 +60,7 @@ public static Charset detect(File file, Charset... charsets) {
* @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);
}

/**
Expand Down
Expand Up @@ -3,6 +3,7 @@
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;
Expand All @@ -16,4 +17,12 @@ public void detectTest(){
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);
}
}

0 comments on commit 52496bb

Please sign in to comment.