The following code shows up as a question mark instead of a degree sign:
var airF = Math.round(Number(MDTMOBILE.RWISWeather[i].AirTemp)) + "\u00B0" + "F";
$('.tempTable').find('td').eq(4).text(airF);
var relHum = Math.round(MDTMOBILE.RWISWeather[i].RH) + "%";
$('.tempTable').find('td').eq(5).text(relHum);
var dewF = Math.round(Number(MDTMOBILE.RWISWeather[i].Dewpoint)) + "\u00B0" + "F";
$('.tempTable').find('td').eq(6).text(dewF);
It displays as: Temp RH Dew 54�F 38% 29�F
Am I using the wrong unicode? "\u00B0"
The notation "\u00B0" is a correct way to use the degree sign in a character literal. But you can also write the character directly, "°", provided that character encoding has been selected and announced properly, as it should.
If you see “�” on a web page, the most common reason is that the character encoding of an HTML document is windows-1252 (or iso-8859-1) but the declared encoding is utf-8. However, in this case, such problems should not arise, because the string is generated in JavaScript, and JavaScript and the DOM internally use UTF-16 for characters data, no matter what the document’s encoding is. To analyze what goes wrong, I think we need a self-contained demo that reproduces the problem, and/or a URL of a demo.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With