got Find Communities to work

This commit is contained in:
2025-10-21 21:43:00 -06:00
parent 7e3b1d535f
commit fe6d53a965
6 changed files with 254 additions and 21 deletions
+31
View File
@@ -12,6 +12,7 @@ package util
import (
"regexp"
"strings"
"unicode"
)
@@ -40,6 +41,36 @@ func CapitalizeString(s string) string {
return ""
}
/* SqlEscape escapes a string in SQL terms.
* Parameters:
* s - The string to be escaped.
* wildcards - If true, also escape the wildcard characters % and _.
* Returns:
* The escaped string.
*/
func SqlEscape(s string, wildcards bool) string {
var sb strings.Builder
for i := 0; i < len(s); i++ {
c := s[i]
switch c {
case '\\', 0, '\n', '\r', '\'', '"':
sb.WriteByte('\\')
sb.WriteByte(c)
case '\032':
sb.WriteByte('\\')
sb.WriteByte('Z')
case '%', '_':
if wildcards {
sb.WriteByte('\\')
}
sb.WriteByte(c)
default:
sb.WriteByte(c)
}
}
return sb.String()
}
/* IsNumeric returns true if the string is numeric (all digits).
* Parameters:
* s - String to be tested.