From eb9cd40ec6264b45546d5b5b06d47be084aacf8b Mon Sep 17 00:00:00 2001 From: merith-tk Date: Sun, 3 Nov 2024 12:57:22 -0800 Subject: [PATCH] push unicode update --- .gitignore | 2 ++ main.go | 2 ++ unicode.go | 15 +++++++++++++++ 3 files changed, 19 insertions(+) create mode 100644 .gitignore create mode 100644 unicode.go diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..267d810 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +mods +disabled diff --git a/main.go b/main.go index 65504f4..8b5d3fc 100644 --- a/main.go +++ b/main.go @@ -64,7 +64,9 @@ func main() { // read the mod.json file and return the name, version, and filename name, version, loader := readMod("./mods/" + file.Name()) + name = cleanUnicode(name) name = cleanPattern.ReplaceAllString(name, "") + if loader != "" { err := os.Rename("./mods/"+file.Name(), "./mods/"+name+"-"+version+".jar") if err != nil { diff --git a/unicode.go b/unicode.go new file mode 100644 index 0000000..bec8b33 --- /dev/null +++ b/unicode.go @@ -0,0 +1,15 @@ +package main + +import ( + "fmt" + "strings" +) + +func cleanUnicode(s string) string { + for _, r := range s { + if r > 127 { + s = strings.ReplaceAll(s, string(r), fmt.Sprintf("&#%d;", r)) + } + } + return s +}