2016-11-21 15:59:17 +00:00
|
|
|
package common
|
|
|
|
|
|
|
|
import (
|
|
|
|
"unicode"
|
|
|
|
)
|
|
|
|
|
|
|
|
// SanitiseString removes all control codes from a string.
|
|
|
|
func SanitiseString(s string) string {
|
|
|
|
n := make([]rune, 0, len(s))
|
|
|
|
for _, c := range s {
|
2016-11-23 19:19:11 +00:00
|
|
|
if c == '\n' || !unicode.Is(unicode.Other, c) {
|
2016-11-21 15:59:17 +00:00
|
|
|
n = append(n, c)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return string(n)
|
|
|
|
}
|