photoprism/pkg/clean/unicode.go
Michael Mayer ae130dc500 Metadata: Sanitize bad Unicode strings #2897
Signed-off-by: Michael Mayer <michael@photoprism.app>
2022-11-15 14:45:21 +01:00

21 lines
266 B
Go

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()
}