Degree symbol incorrectly encoded in HTML page

Hi everyone,

The degree symbol for temperatures appears incorrectly encoded in the output of some pages. What comes in the HTML is the ASCII character itself (176 in decimal, 0xB0 in hex). It is neither HTML-encoded as ° nor does it come as a two-byte UTF-8 sequence (as expected because the server’s response header says the page is encoded in UTF-8). Here’s what I see (near the top-left corner of the page at High Park Village Weather Station - Home):
degree

I have tried a workaround by attempting to remove the degree symbol from the output but all the settings I have found do not actually have the degree symbol as part of the template so it should not be there. This is what I checked:

  • in testtags.php (available [here], High Park Village Weather Station - testtags) the incorrectly encoded degree symbol can also be seen in the line starting with $temperature. In the same file, the unit of measure is without the degree symbol, as seen in the line $uomtemp = 'C';
  • in the script that produces that particular section of the page, ajax-dashboard-2022.php, the unit of measure is set with a correctly-encoded symbol: $uomTemp = ' °C';
  • in Settings.php, the unit of measure for temperatures is set as a site variable without the degree symbol as well in the line $SITE['uomTemp'] = ' C';

I’m quite baffled where the degree symbol comes from. Any ideas?

Thanks,
Marian

So it looks like your webserver is including a header of

content-type: text/html; charset=UTF-8

which forces all pages to use UTF-8. However, the Base-Canada template set uses ISO-8859-1 throughout, so it is expected the degree sign would be problematic.

In your document root of the website, you can put a .htaccess file to tell the webserver to NOT include the default character set (and let the template do that for you).

AddCharset iso-8859-1 .html .css .php .txt .js

for Base-Canada or Base-USA templates which use ISO-8859-1 for all parts.

Also… you need some updates to scripts on your site – use check-fetch-times.php?show=versions to get a list of needed updates and a link to acquire the updates.

I hope this helps…
Best regards,
Ken

I tried but it didn’t make any difference, the server still returns UTF-8 in its header, maybe a script overrides the setting. Aside from the encoding problem itself, it’s still not clear where the degree symbol comes from, given that it’s not set anywhere that I found so far.
Thanks,
Marian

Check the hoster’s control panel for settings – you may be able to specify the default character set to ISO-8859-1 there.

If your customized dashboard uses a degree-sign character literal, then change that to ° instead.