when I try to create a string to send info to my LCD, I get compiler errors on some characters.
sclr[] = {'\140', '1'} // as are 254, 255, 212 and a lot of others
is OK, but
sclr[] = {'\139', '1'}
is not - neither is 128, 192, 148 and who know how many others.
Just happens that those are characters I NEED to send
If I use '\fe' or '\d4' instead, the compiler buys it but I'm not sure it's really doing what I want. ... OK - Now, I'm SURE it's not doing what I want. Still don't know what it IS doing, but it's NOT putting the hex value into the string position I wanted.
Steve
illegal characters - conversions inside 'strings'
Re: illegal characters - conversions inside 'strings'
escape sequence can be either:sadavis80 wrote:when I try to create a string to send info to my LCD, I get compiler errors on some characters.
sclr[] = {'\140', '1'} // as are 254, 255, 212 and a lot of others
is OK, but
sclr[] = {'\139', '1'}
is not - neither is 128, 192, 148 and who know how many others.
Just happens that those are characters I NEED to send
If I use '\fe' or '\d4' instead, the compiler buys it but I'm not sure it's really doing what I want. ... OK - Now, I'm SURE it's not doing what I want. Still don't know what it IS doing, but it's NOT putting the hex value into the string position I wanted.
Steve
\O any O = string of up to 3 octal digits
or
\xH any H = string of hex digits
since you have written '\140' it is octal representation which is correct
all other chars that report errors
(128, 192, 148 ... ) have illegal numbers for octal representation
(only 0..7 are allowed)
please read more carefully our help or any book about C language.
this is section from help.
Escape Sequences
A backslash character (\) is used to introduce an escape sequence, which allows a visual representation of certain nongraphic characters. One of the most common escape constants is the newline character (\n).
A backslash is used with octal or hexadecimal numbers to represent an ASCII symbol or control code corresponding to that value; for example, '\x3F' for the question mark. Any value within legal range for data type char (0 to 0xFF for the mikroC PRO for AVR) can be used. Larger numbers will generate the compiler error “Out of range”.
For example, the octal number \777 is larger than the maximum value allowed (\377) and will generate an error. The first nonoctal or nonhexadecimal character encountered in an octal or hexadecimal escape sequence marks the end of the sequence.
Note: You must use the sequence \\ to represent an ASCII backslash, as used in operating system paths.
The following table shows the available escape sequences:
Sequence Value Char What it does
\a 0x07 BEL Audible bell
\b 0x08 BS Backspace
\f 0x0C FF Formfeed
\n 0x0A LF Newline (Linefeed)
\r 0x0D CR Carriage Return
\t 0x09 HT Tab (horizontal)
\v 0x0B VT Vertical Tab
\\ 0x5C \ Backslash
\' 0x27 ' Single quote (Apostrophe)
" 0x22 " Double quote
\? 0x3F ? Question mark
\O any O = string of up to 3 octal digits
\xH any H = string of hex digits
\XH any H = string of hex digits