重载subtractToList方法,提供isLinked选项(pr#3923@Github)

This commit is contained in:
Looly
2025-04-21 18:22:42 +08:00
parent 0479a8e831
commit fd049cef71
2 changed files with 7 additions and 5 deletions
+2 -1
View File
@@ -2,7 +2,7 @@
# 🚀Changelog
-------------------------------------------------------------------------------------------------------------
# 5.8.38(2025-04-17)
# 5.8.38(2025-04-21)
### 🐣新特性
* 【core 】 `PathUtil#del`增加null检查(pr#1331@Gitee)
@@ -10,6 +10,7 @@
* 【crypto 】 增加`Argon2`类,实现Argon2算法(issue#3890@Github)
* 【core 】 `CharSequenceUtil`增加toLoweCase和toUpperCase方法(issue#IC0H2B@Gitee)
* 【core 】 增加分段锁实现`SegmentLock`(pr#1330@Gitee)
* 【core 】 重载subtractToList方法,提供isLinked选项(pr#3923@Github)
### 🐞Bug修复
* 【setting】 修复`Setting`autoLoad可能的加载为空的问题(issue#3919@Github)
@@ -1,15 +1,16 @@
package cn.hutool.core.text;
import cn.hutool.core.lang.Console;
import cn.hutool.core.util.StrUtil;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
public class IssueI96LWHTest {
@Test
public void replaceTest() {
String str = "\uD83D\uDC46最上方点击蓝字";
Console.log(str.codePoints().toArray());
Console.log(StrUtil.replaceByCodePoint(str, 3, 4, "下"));
Console.log(new StringBuilder(str).replace(3, 4, "下"));
Assertions.assertArrayEquals(new int[]{128070, 26368, 19978, 26041, 28857, 20987, 34013, 23383}, str.codePoints().toArray());
// 这个方法里\uD83D\uDC46表示一个emoji表情,使用codePoint之后,一个表情表示一个字符,因此按照一个字符对
Assertions.assertEquals("\uD83D\uDC46最上下点击蓝字", StrUtil.replaceByCodePoint(str, 3, 4, "下"));
Assertions.assertEquals("\uD83D\uDC46最下方点击蓝字", new StringBuilder(str).replace(3, 4, "下").toString());
}
}