mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
Unicode: provide an ability to supplement the case-mapping tables
in character and string case mapping routines. Add a custom mapper for Turkish and Azeri. A more general solution for deriving the case information from Unicode's SpecialCasing.txt will require more work. Fixes #703. R=rsc, rsc1 CC=golang-dev, mdakin https://golang.org/cl/824043
This commit is contained in:
parent
c2f3737cb0
commit
4e2b7f8f41
6 changed files with 133 additions and 5 deletions
|
|
@ -291,6 +291,24 @@ func ToLower(s string) string { return Map(unicode.ToLower, s) }
|
|||
// ToTitle returns a copy of the string s with all Unicode letters mapped to their title case.
|
||||
func ToTitle(s string) string { return Map(unicode.ToTitle, s) }
|
||||
|
||||
// ToUpperSpecial returns a copy of the string s with all Unicode letters mapped to their
|
||||
// upper case, giving priority to the special casing rules.
|
||||
func ToUpperSpecial(_case unicode.SpecialCase, s string) string {
|
||||
return Map(func(r int) int { return _case.ToUpper(r) }, s)
|
||||
}
|
||||
|
||||
// ToLowerSpecial returns a copy of the string s with all Unicode letters mapped to their
|
||||
// lower case, giving priority to the special casing rules.
|
||||
func ToLowerSpecial(_case unicode.SpecialCase, s string) string {
|
||||
return Map(func(r int) int { return _case.ToLower(r) }, s)
|
||||
}
|
||||
|
||||
// ToTitleSpecial returns a copy of the string s with all Unicode letters mapped to their
|
||||
// title case, giving priority to the special casing rules.
|
||||
func ToTitleSpecial(_case unicode.SpecialCase, s string) string {
|
||||
return Map(func(r int) int { return _case.ToTitle(r) }, s)
|
||||
}
|
||||
|
||||
// Trim returns a slice of the string s, with all leading and trailing white space
|
||||
// removed, as defined by Unicode.
|
||||
func TrimSpace(s string) string {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue