mirror of https://github.com/01-edu/public.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
350 B
22 lines
350 B
5 years ago
|
package correct
|
||
5 years ago
|
|
||
|
import (
|
||
|
"strings"
|
||
5 years ago
|
"unicode"
|
||
5 years ago
|
)
|
||
|
|
||
|
func Capitalize(s string) string {
|
||
|
r := []rune(strings.ToLower(s))
|
||
|
|
||
5 years ago
|
if unicode.IsLower(r[0]) {
|
||
|
r[0] = unicode.ToUpper(r[0])
|
||
5 years ago
|
}
|
||
|
|
||
|
for i := 1; i < len(r); i++ {
|
||
5 years ago
|
if !unicode.Is(unicode.ASCII_Hex_Digit, r[i-1]) && unicode.IsLower(r[i]) {
|
||
|
r[i] = unicode.ToUpper(r[i])
|
||
5 years ago
|
}
|
||
|
}
|
||
|
return string(r)
|
||
|
}
|