2022-04-15 09:42:07 +02:00
|
|
|
package clean
|
|
|
|
|
|
|
|
// ASCII removes all non-ascii characters from a string and returns it.
|
|
|
|
func ASCII(s string) string {
|
2024-01-15 13:06:27 +01:00
|
|
|
if s == "" {
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
|
2022-04-15 09:42:07 +02:00
|
|
|
result := make([]rune, 0, len(s))
|
|
|
|
|
|
|
|
for _, r := range s {
|
|
|
|
if r <= 127 {
|
|
|
|
result = append(result, r)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return string(result)
|
|
|
|
}
|