From ee02e7575eff92aa5307bb2a933252ab4b49aa95 Mon Sep 17 00:00:00 2001 From: Aadhavan Srinivasan Date: Sat, 23 Nov 2024 09:26:27 -0500 Subject: [PATCH] Added function to generate all case variations of a rune --- misc.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/misc.go b/misc.go index 7bbb8eb..ac14cc1 100644 --- a/misc.go +++ b/misc.go @@ -2,6 +2,7 @@ package main import ( "slices" + "unicode" ) var whitespaceChars = []rune{' ', '\t', '\n'} @@ -111,3 +112,12 @@ func genRange(start, end int) []int { } return toRet } + +// Returns a rune-slice containing all possible cases of the given rune. +// At the moment, this includes: +// 1. Upper case +// 2. Lower case +// 3. Title case +func allCases(r rune) []rune { + return []rune{unicode.ToLower(r), unicode.ToUpper(r), unicode.ToTitle(r)} +}