Go Down

Topic: Printing special characters (Read 2857 times) previous topic - next topic

ninja2

Where can I find a list of all the special characters for char arrays and printing, like \n, \o and similar

Also how would I print the little superscripted 'o' symbol for degrees C or F, e.g. in 27<degrees symbol>C

TIA

Morris Dovey

From The C Programming Language:

\a   alert (bell) character
\b   backspace
\f   formfeed
\n   newline (linefeed)
\r   carriage return
\t   horizontal tab
\v   vertical tab
\\   backslash
\?   question mark
\'   single quote
\ddd octal constant
\xhh hexadecimal constant

The degree symbol (as in 27°C) is unknown to C and (I think) C++ and printing it will probably involve device dependencies.
There's always a better way!

Tumbleweed

Ninja2,
Try this page, you can even create your own custom character.
http://www.quinapalus.com/hd44780udg.html
TomJ
Einstein once said you don't really understand anything until you can explain it to your Grandmother

Tumbleweed

Ninja2,
Just read a way to print the degree symbol on another post.
It's at the  bottom of the alternative code for averaging.
http://arduino.cc/forum/index.php/topic,99557.0.html
TomJ
Einstein once said you don't really understand anything until you can explain it to your Grandmother

ninja2

#4
Apr 03, 2012, 12:35 pm Last Edit: Apr 03, 2012, 09:04 pm by ninja2 Reason: 1
excellent help, thanks all

I must use/learn that list of backslash codes ...

found the magic syntax too ...

Code: [Select]
lcd.print((char)223);    // degree

yeeha  :)  :)    


... great forum, friendly players, top advice, fascinating topic(s) :)

ninja2

The degree symbol (as in 27°C) ...


Morris - how did you insert / type the degree symbol into your text above ?

Morris Dovey

On this keyboard the degree symbol is shift+option+8 (An * that's turned into a ° by the option key).

You can do the same thing on a Windows keyboard by holding down the Alt key and typing in a code on the numeric keypad - but I've already forgotten the code.  :-(
There's always a better way!

ninja2

º how about alt+0186 º  :)
ºXºXºXº
google is so amazing these days, I just googled "How to type degree symbol on PC" and bingo

liudr


º how about alt+0186 º  :)
ºXºXºXº
google is so amazing these days, I just googled "How to type degree symbol on PC" and bingo


Next day Google will push books ad to you that features a whole chapter on "How to type degree symbol on PC"  ;)

Morris Dovey

If the Extended ASCII code is 233, then you should be able to embed it in a string as

   char *temperature = "Today's high temperature is 27\xE9""C"

But my wimpy bash terminal window displays it as a question mark.  :-/
There's always a better way!

oric_dan

from Morris:
\n   newline (linefeed)
\r   carriage return

I assume \r sends only a 13, but does \n send only a 10, or both 10 + 13?

PaulS

Quote
I assume \r sends only a 13, but does \n send only a 10, or both 10 + 13?

Depends on what is doing the sending, on what operating system.

oric_dan

Quote

Depends on what is doing the sending, on what operating system.


How about this one: Serial.print("\n");

ninja2

Next day Google will push books ad to you that features a whole chapter on "How to type degree symbol on PC"  ;)


LOL , and I'm a the perfect target for such :)

PaulS

Quote
How about this one: Serial.print("\n");

Sends exactly one byte - the new line value, 10. to the serial port.

Go Up