From 75893179350ecef398f364fc87a00886d2e34018 Mon Sep 17 00:00:00 2001 From: Rob Pike Date: Tue, 30 Mar 2010 17:51:03 -0700 Subject: 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 --- src/pkg/strings/strings.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/pkg/strings/strings.go') 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 { -- cgit v1.2.3