| 229 | } |
| 230 | |
| 231 | func (e *Encoder) computeStringStatistics(input string) *stringStatistics { |
| 232 | digitCount, upperCount := 0, 0 |
| 233 | canLowerSpecialEncoded := true |
| 234 | canLowerUpperDigitSpecialEncoded := true |
| 235 | for _, c := range []byte(input) { |
| 236 | if canLowerUpperDigitSpecialEncoded { |
| 237 | if !(c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || |
| 238 | c >= '0' && c <= '9' || c == e.specialChar1 || c == e.specialChar2) { |
| 239 | canLowerUpperDigitSpecialEncoded = false |
| 240 | } |
| 241 | } |
| 242 | |
| 243 | if canLowerSpecialEncoded { |
| 244 | if !(c >= 'a' && c <= 'z' || c == '.' || c == '_' || c == '$' || c == '|') { |
| 245 | canLowerSpecialEncoded = false |
| 246 | } |
| 247 | } |
| 248 | |
| 249 | if c >= '0' && c <= '9' { |
| 250 | digitCount++ |
| 251 | } |
| 252 | |
| 253 | if c >= 'A' && c <= 'Z' { |
| 254 | upperCount++ |
| 255 | } |
| 256 | } |
| 257 | return &stringStatistics{ |
| 258 | digitCount: digitCount, |
| 259 | upperCount: upperCount, |
| 260 | canLowerSpecialEncoded: canLowerSpecialEncoded, |
| 261 | canLowerUpperDigitSpecialEncoded: canLowerUpperDigitSpecialEncoded, |
| 262 | } |
| 263 | } |
| 264 | |
| 265 | func countUppers(str string) int { |
| 266 | cnt := 0 |