diff options
| author | Rob Pike <r@golang.org> | 2010-03-30 17:51:03 -0700 |
|---|---|---|
| committer | Rob Pike <r@golang.org> | 2010-03-30 17:51:03 -0700 |
| commit | 4e2b7f8f41a8ab58489354ff0e2c10a867a4a354 (patch) | |
| tree | 58a577de4e9ea917e8a68588526a537e5c0b62bd /src/pkg/strings/strings.go | |
| parent | c2f3737cb01bf35991a775c14cd28e5a2d3a102e (diff) | |
| download | go-4e2b7f8f41a8ab58489354ff0e2c10a867a4a354.tar.xz | |
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
Diffstat (limited to 'src/pkg/strings/strings.go')
| -rw-r--r-- | src/pkg/strings/strings.go | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/pkg/strings/strings.go b/src/pkg/strings/strings.go index 24aac10e9e..4268551374 100644 --- a/src/pkg/strings/strings.go +++ b/src/pkg/strings/strings.go @@ -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 { |
