File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -11,15 +11,15 @@ import (
1111 "sort"
1212 "strings"
1313 "sync"
14+ "unicode"
1415)
1516
1617var (
1718 idAlphabet = []byte ("abcdefghijklmnopqrstuvwxyz" )
1819 smartQuoteRgx = regexp .MustCompile (`^(?i)"?[a-z_][_a-z0-9\-]*"?(\."?[_a-z][_a-z0-9]*"?)*(\.\*)?$` )
1920
20- rgxEnum = regexp .MustCompile (`^enum(\.[a-zA-Z0-9_]+)?\([^\)]+\)$` )
21- rgxWhitespace = regexp .MustCompile (`\s` )
22- rgxAlphanumericAndUnderscores = regexp .MustCompile ("[^a-zA-Z0-9_]+" )
21+ rgxEnum = regexp .MustCompile (`^enum(\.[a-zA-Z0-9_]+)?\([^\)]+\)$` )
22+ rgxWhitespace = regexp .MustCompile (`\s` )
2323)
2424
2525func AddUppercase (s string ) {
@@ -252,7 +252,16 @@ func TitleCase(n string) string {
252252 return val
253253 }
254254
255- cleanN := rgxAlphanumericAndUnderscores .ReplaceAllLiteralString (n , "_" )
255+ var cleanN string
256+ for _ , r := range n {
257+ var char string
258+ if unicode .IsLetter (r ) || unicode .IsDigit (r ) {
259+ char = string (r )
260+ } else {
261+ char = "_"
262+ }
263+ cleanN += char
264+ }
256265
257266 // If the string is made up of only uppercase letters and underscores,
258267 // then return as is and do not strip the underscores
@@ -711,7 +720,7 @@ func ParseEnumName(s string) string {
711720 return s [startIndex + 1 :]
712721}
713722
714- //StripWhitespace removes all whitespace from a string
723+ // StripWhitespace removes all whitespace from a string
715724func StripWhitespace (value string ) string {
716725 return rgxWhitespace .ReplaceAllString (value , "" )
717726}
You can’t perform that action at this time.
0 commit comments