Tried adding 'signed' and it does solve this problem 8)
I have been a programmer for over 30 years and this is the first 'C' compiler I have used that does not treat a 'char' as signed.
In fact this is a copy of the section from the online reference:-
The char datatype is a signed type, meaning that it encodes numbers from -128 to 127. For an unsigned, one-byte (8 bit) data type, use the byte data type.
Anyway, many thanks for your help, I should have thought of trying that for myself!
BTW, your reference is wrong. It may be true of particular implementations, but the definition of C has always left the signed-ness of char up to the implementation (whether right shift sign extends or zero extends is another). I was on the original ANSI X3J11 committee that produced the C89 and C90 standards (I dropped mid-way before the C99 standard came out), and implemented a C compiler before the standards process began, so in this one case, I know what I'm talking about.
There are various compilers out there that default to unsigned chars. Lets see, the PowerPC and ARM GCC compilers both default to char being unsigned, as did the Data General MV/Eclipse compiler I wrote many years ago. So, if you use a Due, it likely defaults to unsigned char's unless the IDE uses the -fsigned-char option.
In terms of holding characters, it should have been unsigned so that you could use it as an index. However, C was developed on DEC hardware (PDP-7 and then PDP-11) that only had load byte with sign extension, and it was developed at a time in the US which at the time used the 7-bit encoding for characters, so all of the printable characters were positive even if bytes were signed. When the world went to 8-bit encoding, many of the additional characters in the European languages had the high bit set. This means if you wanted to index into a table, you now had to explicitly lop off the upper bits. In addition, the getchar/getc library routines need to return an out of band character to represent EOF, and they return -1.
I met up with Dennis Ritchie (main inventor of C) many years ago, and he said that if he could go back in time and amend C with the benefit of hindsight, one of the changes he would have made would have been to decree that 'char' always be 0..255. It is important to have an 8-bit signed data type, but it shouldn't have been called 'char'.