ASCII symbol in a char is giving weird results

Hi,

I'm trying to concatenate some values to display the temperature on an LCD screen and I'm having trouble adding the º symbol.

Here is my code:

void DisplayTemp(char temp1[6], char temp2[6]){
   char degreSymbol[1] = {223};

   strcpy(lcdLine0, "Panel: ");
   strcat(lcdLine0, temp2);
   strcat(lcdLine0, degreSymbol);
   strcat(lcdLine0, "C");
   Serial.println(lcdLine0);
   DisplayLCD(lcdLine0,lcdLine1);
  }

The results are:
1- On the serial display: Panel: -10.01ß##C
2- On the LCD screen: Panel: -10.01º##C

a- Why are both result different?
b- Where the ## is coming from?

Before I was doing the same thing with strings it was creating error so now I'm trying to use char.

Thanks for your help

char degreSymbol[1] = {223};

this is a pointer with out array an index ()
why not

char degreSymbol = 223;
strcat(lcdLine0, "C");

"C" is a string ( char array ), however 'C' is a character literal

... and try 248 rather than 223.

azzabcd:
a- Why are both result different?

In the ASCII encoding scheme values up to 127 are universal. There are multiple definitions for the values above 127 and you need to know which definition (usually referred to as a 'code page') is being used in order to interpret them. The symptoms suggest that the Arduino Serial monitor and the LCD are not using the same code page - one is interpreting your ASCII code to mean the symbol you intended, and the other isn't.

The ## is coming from the fact that your degree symbol is not a null terminated string so strcat keeps going until it finds a 0. Try this:

   char degreSymbol[] = {223,0};

Or better still, this:

   char degreSymbol[] = {223,'C',0}; //print degrees C all in one go, means you don't need this: "strcat(lcdLine0, "C");"

Hey, many thanks for everybody. It took me some time, but weith your suggestions, I've been able to do exactly what I was trying.

Thanks again