For portable applications, use only the assignment =
operator, the equality operators ==
and !=
, and the unary &
operator on plain character or plain wide character-typed expressions.
...
However, due to the requirement for digit characters, the usage of other operators is allowed can be used for them according to the following restrictions:
- The binary
+
operator may be used to add integer values from 0 to 9 to '0'. - The binary
-
operator may be used to subtract character '0'. - Relational operators
<
,<=
,>
, and>=
may can be used to check whether a character or wide character is a digit.
...
Noncompliant Code Example
The following example would seem appears to check if the value of a character variable is between 'a'
and 'c'
inclusive. However, since it is not required by the C99 standard that does not require the letter characters to be consecutive nor or in alphabetical order, the check might not work as expected.
...
Exceptions
STR09-EX1: It is ok okay to assume consecutive value values for characters like a~z
on platforms where ASCII or Unicode is used. This rule is to raise for raising awareness of platform portability, such as if the code is migrated from ASCII systems to non-ASII systems.
...