fix cutting utf-8 strings #82

This commit is contained in:
piotr
2023-01-12 02:27:27 +01:00
parent 8ff2d5c89c
commit cedcf8619f
2 changed files with 22 additions and 9 deletions

View File

@@ -691,3 +691,19 @@ func mapOutputs() (map[string]*gdk.Monitor, error) {
}
return result, nil
}
// KAdot / https://stackoverflow.com/a/38537764/4040598 - thanks!
func substring(s string, start int, end int) string {
startStrIdx := 0
i := 0
for j := range s {
if i == start {
startStrIdx = j
}
if i == end {
return s[startStrIdx:j]
}
i++
}
return s[startStrIdx:]
}