diff --git a/internal/string.go b/internal/string.go index 2116b03..b243b24 100644 --- a/internal/string.go +++ b/internal/string.go @@ -59,7 +59,13 @@ func CharAt(s string, i int) byte { // ToTitle returns a copy of the string m with its first Unicode letter mapped // to its title case. -func ToTitle(m string) string { +func ToTitle(m string, strict bool) string { r, size := utf8.DecodeRuneInString(m) - return string(unicode.ToTitle(r)) + strings.ToLower(m[size:]) + + other := m[size:] + if strict { + other = strings.ToLower(other) + } + + return string(unicode.ToTitle(r)) + other } diff --git a/strcase/sentence.go b/strcase/sentence.go index a49ea35..d5476e6 100644 --- a/strcase/sentence.go +++ b/strcase/sentence.go @@ -65,7 +65,7 @@ func (sc *SentenceConverter) Convert(s string) string { if entry := sc.inVocab(token); entry != "" { made = append(made, entry) } else if i == 0 || sc.indicator(prev, i-1) { - made = append(made, internal.ToTitle(token)) + made = append(made, internal.ToTitle(token, true)) } else { made = append(made, strings.ToLower(token)) } diff --git a/strcase/title.go b/strcase/title.go index b17f3b9..30fb09f 100644 --- a/strcase/title.go +++ b/strcase/title.go @@ -97,7 +97,8 @@ func (tc *TitleConverter) Convert(s string) string { (internal.CharAt(t, pos+ext) != '-' || internal.CharAt(t, pos-1) == '-') { return sm } - return internal.ToTitle(m) + + return internal.ToTitle(m, false) }) }