isPrintable reports whether a string contains only printable runes.
(str string)
| 201 | |
| 202 | // isPrintable reports whether a string contains only printable runes. |
| 203 | func isPrintable(str string) bool { |
| 204 | const firstPrintable = 32 // ASCII space |
| 205 | |
| 206 | for _, r := range str { |
| 207 | if r < firstPrintable || r > unicode.MaxASCII { |
| 208 | return false |
| 209 | } |
| 210 | } |
| 211 | |
| 212 | return true |
| 213 | } |
| 214 | |
| 215 | // vetIdentifiers checks all identifiers respect some rule so that we can use |
| 216 | // them safely in queries. |