photoprism/pkg/clean/unicode.go

22 lines
266 B
Go
Raw Normal View History

package clean
import "strings"
// Unicode returns a string a valid unicode.
func Unicode(s string) string {
if s == "" {
return ""
}
var b strings.Builder
for _, c := range s {
if c == '\uFFFD' {
continue
}
b.WriteRune(c)
}
return b.String()
}