summaryrefslogtreecommitdiffstats
path: root/lib/str.go
diff options
context:
space:
mode:
Diffstat (limited to 'lib/str.go')
-rw-r--r--lib/str.go14
1 files changed, 9 insertions, 5 deletions
diff --git a/lib/str.go b/lib/str.go
index 8211ea8..8db415f 100644
--- a/lib/str.go
+++ b/lib/str.go
@@ -123,15 +123,19 @@ func StrSplitAt(c byte, s string) []string {
func StrToUpper(s string) string {
us := ""
for i := 0; i < len(s); i++ {
- if 'a' <= s[i] && s[i] <= 'z' {
- us += string('A' + (s[i] - 'a'))
- } else {
- us += string(s[i])
- }
+ us += string(ByteToUpper(s[i]))
}
return us
}
+func ByteToUpper(b byte) byte {
+ if 'a' <= b && b <= 'z' {
+ return 'A' + (b - 'a')
+ } else {
+ return b
+ }
+}
+
// Returns true if string 's' has string 'n' in it.
func StrHas(s, n string) bool {
for i := 0; i < len(s); i++ {