Notifications
Clear all

[Solved] I can't figure out a character in webserver

3 Posts
2 Users
1 Reactions
1,347 Views
MadMisha
(@madmisha)
Member
Joined: 4 years ago
Posts: 340
Topic starter  

I am running an ESP32 and have a simple webserver. It is displaying the current temperature and humidity. It is temporary and will be removed after testing.

 

The problem is that when I try to use the degree symbol(°, copied and pasted from a website, I have tried a few) I get an A character. The variable is a float but it's just the simple string with °C that causes it. Since it's for testing, there is no formatting. Any ideas on this?

 

client.print(String(temps));
client.print("°C");
//what I get is 

//26.88°C

 


   
Quote
(@davee)
Member
Joined: 3 years ago
Posts: 1794
 

Hi @madmisha,

  Sorry, I don't have an answer to what is happening in your case, and I can't quickly simulate the client.print (), but I hoped it should be the same as a more 'conventional' web task, assuming client.print() just blindly transmits the same characters, and it is the web browser that does the interpretation.

   A quick Google served up a discussion on how to do the degree sign with a couple of answers:

https://stackoverflow.com/questions/10797686/best-way-to-encode-degree-celsius-symbol-into-web-page

And a quick trial on W3schools.com 'Try me' seemed to work.

<!DOCTYPE html>
<html>
<body>

<p>My room temperature 20&deg;C</p>

</body>
</html>

 So maybe this would work on your embedded system?

Good luck and best wishes!


   
ReplyQuote
MadMisha
(@madmisha)
Member
Joined: 4 years ago
Posts: 340
Topic starter  

@davee

That worked perfectly. I guess my google foo is off today. I kept looking up examples since that kind of project has been done to death and they all just put an F after the temp and that just wasn't working well with my OCD. I guess that was why. Thanks.


   
DaveE reacted
ReplyQuote