summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrsiddharth <s@ricketyspace.net>2021-03-06 15:45:46 -0500
committerrsiddharth <s@ricketyspace.net>2021-03-06 15:45:46 -0500
commit1284c582a914c942dd2bd21b1749bf6567515d2b (patch)
treeed54db71b47c8e96c51beff9fd44766d7469cbd7
parent51cce8132d7bd21f51613a1a78ea6652ffb222f4 (diff)
lib: add ByteToUpper
-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++ {