...
Code Block | ||
---|---|---|
| ||
char ch = 'b'; if ( ( ch >= 'a' ) && (ch <= 'c')) ){ /* ... */ } |
Compliant Solution
In this example, the specific check is enforced using compliant operations on character expressions.
Code Block | ||
---|---|---|
| ||
char ch = 't'; if ( ( ch == 'a' ) || ( ch == 'b') || ( ch == 'c')) ){ /* ... */ } |
Exceptions
STR09-EX1: It is ok to assume consecutive value for characters like a~z
on platforms where ASCII or Unicode is used. This rule is to raise awareness of platform portability, such as if the code is migrated from ASCII systems to non-ASII systems.
...