mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
add method
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package cn.hutool.core.text;
|
||||
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -65,4 +66,16 @@ public class CharSequenceUtilTest {
|
||||
index = CharSequenceUtil.indexOf("abc123", 'b', 0, 3);
|
||||
Assert.assertEquals(1, index);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void subPreGbkTest(){
|
||||
// https://gitee.com/dromara/hutool/issues/I4JO2E
|
||||
String s = "华硕K42Intel酷睿i31代2G以下独立显卡不含机械硬盘固态硬盘120GB-192GB4GB-6GB";
|
||||
|
||||
String v = CharSequenceUtil.subPreGbk(s, 40, false);
|
||||
Assert.assertEquals(39, v.getBytes(CharsetUtil.CHARSET_GBK).length);
|
||||
|
||||
v = CharSequenceUtil.subPreGbk(s, 40, true);
|
||||
Assert.assertEquals(41, v.getBytes(CharsetUtil.CHARSET_GBK).length);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user