26 lines
435 B
Go
26 lines
435 B
Go
package blog
|
|
|
|
import (
|
|
"unicode"
|
|
)
|
|
|
|
const TimeFormat string = "2006-01-02 15:04"
|
|
|
|
func isASCII(r rune) bool {
|
|
return r <= 127
|
|
}
|
|
|
|
func ConvASCII(s string) string {
|
|
out := []rune(s)
|
|
for i, c := range out {
|
|
if (isASCII(c) && (unicode.IsLetter(c) || unicode.IsDigit(c))) || c == '.' {
|
|
// keep unchanged
|
|
} else if unicode.IsSpace(c) || unicode.IsPunct(c) {
|
|
out[i] = '-'
|
|
} else {
|
|
out[i] = 'x'
|
|
}
|
|
}
|
|
return string(out)
|
|
}
|