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 | 75893179350ecef398f364fc87a00886d2e34018 (patch) | |
tree | 82762b3d8f58596447d9628e323924826e3aec9e /src/pkg/strings/strings.go | |
parent | 84eb67e259f260b994ceb5ce9bdf4f974e11de3a (diff) | |
download | golang-75893179350ecef398f364fc87a00886d2e34018.tar.gz |
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 issue 703.
R=rsc, rsc1
CC=golang-dev, mdakin
http://codereview.appspot.com/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 24aac10e9..426855137 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 { |