Can I always assume the characters '0' to '9' appear sequentially in any C character encoding -
i'm writing program in c converts strings integers. way i've implemeted before so
int number = (character - '0');
this works me, started thinking, there systems using obscure character encoding in characters '0' '9' don't appear 1 after in order? code assumes '1' follows '0', '2' follows '1' , on, there ever case when not true?
yes, guaranteed c standard.
n1570 5.2.1 paragraph 3 says:
in both source , execution basic character sets, value of each character after
0
in above list of decimal digits shall 1 greater value of previous.
this guarantee possible because both ascii , ebcdic happen have property.
note there's no corresponding guarantee letters; in ebcdic, letters not have contiguous codes.