Hi All :)
This is probably not a very smart question, :) I feel like I'm supposed to know the answer but I don't. :D
My problem is that I have to add non-printable characters into a string... I know that could be done through putting the ASCII number of the character into '\...' (Was that called an escape sequence?).
I wrote a test string in my program that contains such characters to see how it would work and I was surprised that characters '\008' and '\009' don't become binary 8 ad 9 but ASCII '8' and '9'?!
This is the string:
unsigned char str[] = {'\001', '\002', '\003', '\004', '\005', '\006', '\007', '\008', '\009', '\010' };
unsigned char str[] = "\001\002\003\004\005\006\007\008\009\010";
Also the character '\010' is resolving into binary 8 instead of binary 10, and every time such a code that contains 8 or 9 it again makes ASCII 8 or 9 instead of the code I want, for example:
'\018' = '8' sinstead of binary 18
'\028' = '8'
so on.
I have an old program written by someone else which ontains a string with all the first 32 non-printable characters presented this way and there everything is OK?!
Obviously after every occurance of 8 and 9 the subsequent codes are decreased with 2 so no code is lost, I mean '\010' = binary 8; '\020' = binary 18 etc... so I can (after all) do what I want, but why it has to be confusing like this? And can it be fixed?
Thanks in advance! :)