CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Escaping \1 \11 without my mind escaping me

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Laurent Chouinard



Joined: 12 Sep 2003
Posts: 43

View user's profile Send private message

Escaping \1 \11 without my mind escaping me
PostPosted: Tue May 16, 2006 1:37 pm     Reply with quote

Basically, this string constant is declared in rom:
byte const foobar[10] = {"\1hi there!"};

1st character is binary value 1, because i use the escape sequence to get it in. That's what i want.

Now i need to add the digit 1 after it in the string, or hex value 31

If I do this:
byte const foobar[10] = {"\11hi there"};
I'm doomed! Ascii value 11 goes there instead.

So basically I could do this:
byte const foobar[10] = {"\1\x31hi there"};
But that sure is ugly. Especially to the person who's going to read that and make sense of it when translating or something.

Any ways to stop the escaping to stop escaping? Or maybe i'm just not seeing clear today.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue May 16, 2006 1:57 pm     Reply with quote

Use the full 3 digits of the octal sequence (i.e., \001). Then it works.
Example:
Code:
byte const foobar[12] = {"\0011Hi There!"};

Also note that the array must be 12 bytes in size -- 11 bytes for the
characters and one more for the string terminator.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group