mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-03-01 10:20:16 +01:00
🎨 Remove Unicode PUA characters https://github.com/siyuan-note/siyuan/issues/13291
This commit is contained in:
parent
18f68ac715
commit
7446599c0f
18 changed files with 29 additions and 22 deletions
|
|
@ -242,7 +242,7 @@ func FilterFileName(name string) string {
|
|||
name = strings.ReplaceAll(name, ">", "_")
|
||||
name = strings.ReplaceAll(name, "|", "_")
|
||||
name = strings.TrimSpace(name)
|
||||
name = gulu.Str.RemoveInvisible(name) // Remove invisible characters from file names when uploading assets https://github.com/siyuan-note/siyuan/issues/11683
|
||||
name = RemoveInvalid(name) // Remove invisible characters from file names when uploading assets https://github.com/siyuan-note/siyuan/issues/11683
|
||||
return name
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@ import (
|
|||
"time"
|
||||
"unicode"
|
||||
|
||||
"github.com/88250/gulu"
|
||||
"github.com/88250/lute/html"
|
||||
)
|
||||
|
||||
|
|
@ -133,7 +132,7 @@ func RemoveRedundantSpace(str string) string {
|
|||
}
|
||||
|
||||
func Convert2Float(s string) (float64, bool) {
|
||||
s = gulu.Str.RemoveInvisible(s)
|
||||
s = RemoveInvalid(s)
|
||||
s = strings.ReplaceAll(s, " ", "")
|
||||
s = strings.ReplaceAll(s, ",", "")
|
||||
buf := bytes.Buffer{}
|
||||
|
|
|
|||
|
|
@ -248,7 +248,7 @@ func Tesseract(imgAbsPath string) (ret []map[string]interface{}) {
|
|||
ret = append(ret, dataMap)
|
||||
}
|
||||
|
||||
tsv = gulu.Str.RemoveInvisible(tsv)
|
||||
tsv = RemoveInvalid(tsv)
|
||||
tsv = RemoveRedundantSpace(tsv)
|
||||
msg := fmt.Sprintf("OCR [%s] [%s]", html.EscapeString(info.Name()), html.EscapeString(GetOcrJsonText(ret)))
|
||||
PushStatusBar(msg)
|
||||
|
|
@ -266,7 +266,7 @@ func GetOcrJsonText(jsonData []map[string]interface{}) (ret string) {
|
|||
}
|
||||
}
|
||||
}
|
||||
ret = gulu.Str.RemoveInvisible(ret)
|
||||
ret = RemoveInvalid(ret)
|
||||
ret = RemoveRedundantSpace(ret)
|
||||
return ret
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,6 +56,12 @@ var emojiRegex = regexp.MustCompile(`/([0-9#][\x{20E3}])|` +
|
|||
|
||||
func RemoveEmojiInvisible(text string) (ret string) {
|
||||
ret = emojiRegex.ReplaceAllString(text, "")
|
||||
ret = gulu.Str.RemoveInvisible(ret)
|
||||
ret = RemoveInvalid(ret)
|
||||
return
|
||||
}
|
||||
|
||||
func RemoveInvalid(text string) (ret string) {
|
||||
ret = gulu.Str.RemoveInvisible(text)
|
||||
ret = gulu.Str.RemovePUA(text)
|
||||
return
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue