replace strings.Title to cases.Title (#2650)

This commit is contained in:
EinfachePhy
2022-12-02 00:15:51 +08:00
committed by GitHub
parent 90828a0d4a
commit 10fd9131a1
3 changed files with 30 additions and 2 deletions

View File

@@ -4,6 +4,9 @@ import (
"bytes"
"strings"
"unicode"
"golang.org/x/text/cases"
"golang.org/x/text/language"
)
var WhiteSpace = []rune{'\n', '\t', '\f', '\v', ' '}
@@ -49,12 +52,12 @@ func (s String) Source() string {
return s.source
}
// Title calls the strings.Title
// Title calls the cases.Title
func (s String) Title() string {
if s.IsEmptyOrSpace() {
return s.source
}
return strings.Title(s.source)
return cases.Title(language.English).String(s.source)
}
// ToCamel converts the input text into camel case