add DriverIdentifier

This commit is contained in:
Looly
2023-12-04 23:27:42 +08:00
parent df227d63aa
commit 301968cbbc
17 changed files with 469 additions and 190 deletions

View File

@@ -3201,7 +3201,9 @@ public class CharSequenceUtil extends StrValidator {
}
/**
* 截断字符串使用其按照指定编码为字节后不超过maxBytes长度
* 截断字符串使用其按照指定编码为字节后不超过maxBytes长度<br>
* 此方法用于截取总bytes数不超过指定长度如果字符出没有超出原样输出如果超出了则截取掉超出部分并可选添加...
* 但是添加“...”后总长度也不超过限制长度。
*
* @param str 原始字符串
* @param charset 指定编码

View File

@@ -321,6 +321,13 @@ public class CharSequenceUtilTest {
Assertions.assertEquals(str, ret);
}
@Test
public void limitByteLengthUtf8Test2() {
final String str = "这是This一";
final String ret = StrUtil.limitByteLengthUtf8(str, 12, true);
Assertions.assertEquals("这是Thi...", ret);
}
@Test
public void limitByteLengthTest() {
final String str = "This is English";