-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
现在Web3的搜索面板会自动排除掉空格; 对中间空格会用连接符做尝试
- Loading branch information
Showing
5 changed files
with
87 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 30 additions & 1 deletion
31
next/kmp/helper/src/commonMain/kotlin/org/dweb_browser/helper/stringHelper.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,32 @@ | ||
package org.dweb_browser.helper | ||
|
||
public fun String.removeInvisibleChars(): String = replace(Regex("[\\p{C}\\p{Z}&&[^\\p{Zs}]]"), "") | ||
public fun String.removeInvisibleChars(): String = replace(Regex("[\\p{C}\\p{Z}&&[^\\p{Zs}]]"), "") | ||
|
||
public fun String.humanTrim(): String = trim( | ||
// 零宽字符: | ||
'\u200B',//零宽空格 (ZWSP) | ||
'\u200C',//零宽非连接符 (ZWNJ) | ||
'\u200D',//零宽连接符 (ZWJ) | ||
|
||
// 常见的空白字符: | ||
|
||
'\u0020',// 普通空格 (Space) | ||
'\u00A0',// 不间断空格 (Non-breaking space) | ||
'\u1680',// 赡养符 (Ogham space mark) | ||
'\u2000',// 到 \u200A 一系列空格(各种宽度的空格) | ||
// 格式控制字符(这些字符主要用于控制文本格式,通常在现代文本中不再使用,但在某些场景中仍然可能出现): | ||
|
||
'\u200B',// 零宽空格(Zero Width Space) | ||
'\u200C',// 零宽非连接符(Zero Width Non-Joiner) | ||
'\u200D',// 零宽连接符(Zero Width Joiner) | ||
'\u200E',// 左到右标记(Left-to-Right Mark, LRM) | ||
'\u200F',// 右到左标记(Right-to-Left Mark, RLM) | ||
'\u202A',// 到 \u202E 一些文本方向控制字符(如:右到左方向标记、强制方向标记等) | ||
// 换行符与回车符: | ||
|
||
'\u000A',// 换行符(Line Feed, LF) | ||
'\u000D',// 回车符(Carriage Return, CR) | ||
'\u2028',// 行分隔符(Line Separator) | ||
'\u2029',// 段分隔符(Paragraph Separator) | ||
|
||
) |