This commit is contained in:
Julien Neuhart
2019-08-18 20:03:47 +02:00
parent 4f3fe28905
commit bcf06f0d69
5 changed files with 54 additions and 1 deletions

View File

@@ -0,0 +1,21 @@
package normalize
import (
"unicode"
"github.com/thecodingmachine/gotenberg/internal/pkg/xerror"
"golang.org/x/text/runes"
"golang.org/x/text/transform"
"golang.org/x/text/unicode/norm"
)
// String normalizes given string.
func String(str string) (string, error) {
const op string = "normalize.String"
t := transform.Chain(norm.NFD, runes.Remove(runes.In(unicode.Mn)), norm.NFC)
result, _, err := transform.String(t, str)
if err != nil {
return "", xerror.New(op, err)
}
return result, nil
}