StrUtil.isBlank增加\u200c判断(issue#3903@Github)

This commit is contained in:
Looly 2025-03-24 08:51:12 +08:00
parent 37ab8650c3
commit d191e279d6
3 changed files with 24 additions and 17 deletions

View File

@ -14,6 +14,7 @@
* 【db 】 增加GoldenDB识别pr#3886@Github
* 【http 】 改进`UrlQuery`对无参URL增加判断识别issue#IBRVE4@Gitee
* 【core 】 改进`PropDesc`中去除Transient引用避免NoClassDefFoundErrorissue#3901@Github
* 【core 】 `StrUtil.isBlank`增加`\u200c`判断issue#3903@Github
### 🐞Bug修复
* 【setting】 修复`SettingLoader`load未抛出异常导致配置文件无法正常遍历的问题pr#3868@Github

View File

@ -256,16 +256,18 @@ public class CharUtil implements CharPool {
*/
public static boolean isBlankChar(int c) {
return Character.isWhitespace(c)
|| Character.isSpaceChar(c)
|| c == '\ufeff'
|| c == '\u202a'
|| c == '\u0000'
// issue#I5UGSQHangul Filler
|| c == '\u3164'
// Braille Pattern Blank
|| c == '\u2800'
// MONGOLIAN VOWEL SEPARATOR
|| c == '\u180e';
|| Character.isSpaceChar(c)
|| c == '\ufeff'
|| c == '\u202a'
|| c == '\u0000'
// issue#I5UGSQHangul Filler
|| c == '\u3164'
// Braille Pattern Blank
|| c == '\u2800'
// Zero Width Non-Joiner, ZWNJ
|| c == '\u200c'
// MONGOLIAN VOWEL SEPARATOR
|| c == '\u180e';
}
/**
@ -278,12 +280,12 @@ public class CharUtil implements CharPool {
public static boolean isEmoji(char c) {
//noinspection ConstantConditions
return false == ((c == 0x0) || //
(c == 0x9) || //
(c == 0xA) || //
(c == 0xD) || //
((c >= 0x20) && (c <= 0xD7FF)) || //
((c >= 0xE000) && (c <= 0xFFFD)) || //
((c >= 0x100000) && (c <= 0x10FFFF)));
(c == 0x9) || //
(c == 0xA) || //
(c == 0xD) || //
((c >= 0x20) && (c <= 0xD7FF)) || //
((c >= 0xE000) && (c <= 0xFFFD)) || //
((c >= 0x100000) && (c <= 0x10FFFF)));
}
/**

View File

@ -1,8 +1,9 @@
package cn.hutool.core.util;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
public class CharUtilTest {
@Test
@ -43,6 +44,9 @@ public class CharUtilTest {
final char a5 = ' ';
assertTrue(CharUtil.isBlankChar(a5));
final char a6 = '\u200c';
assertTrue(CharUtil.isBlankChar(a6));
}
@Test