push unicode update
This commit is contained in:
parent
5c2cfc7275
commit
eb9cd40ec6
3 changed files with 19 additions and 0 deletions
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
mods
|
||||||
|
disabled
|
2
main.go
2
main.go
|
@ -64,7 +64,9 @@ func main() {
|
||||||
|
|
||||||
// read the mod.json file and return the name, version, and filename
|
// read the mod.json file and return the name, version, and filename
|
||||||
name, version, loader := readMod("./mods/" + file.Name())
|
name, version, loader := readMod("./mods/" + file.Name())
|
||||||
|
name = cleanUnicode(name)
|
||||||
name = cleanPattern.ReplaceAllString(name, "")
|
name = cleanPattern.ReplaceAllString(name, "")
|
||||||
|
|
||||||
if loader != "" {
|
if loader != "" {
|
||||||
err := os.Rename("./mods/"+file.Name(), "./mods/"+name+"-"+version+".jar")
|
err := os.Rename("./mods/"+file.Name(), "./mods/"+name+"-"+version+".jar")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
15
unicode.go
Normal file
15
unicode.go
Normal file
|
@ -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
|
||||||
|
}
|
Loading…
Reference in a new issue