HTML encoding ° degree symbol extra space

12,923

So the problem is that sometimes there is a space between the ° and the F, that space gets translated into a +, and the server doesn't accept it? If so, why not strip out the space before sending it?

$.get("http://blah.com/go",{'TU':$('#a').text().replace(' ', '')});
// Or a more granular fix
$.get("http://blah.com/go",{'TU':$('#a').text().replace(/°\sF/, '°F')});
Share:
12,923
Zac
Author by

Zac

Updated on June 04, 2022

Comments

  • Zac
    Zac almost 2 years
    1. <div id="a">°F</div>
    2. $.get("http://blah.com/go",{'TU':$('#a').text()});
    3. IIS server logs show the following params:
      99.5% of the time: TU=%C2%B0F
      0.5% of the time: TU=%C2%B0+F
    4. server subsequently crashes because it doesn't know what '° F' is. Admittedly one of the flaws is that we are scraping text out of the DOM & sending it to our server. This is where I suspect the problem is, but I would like to understand more.

    Other info: the 0.5% of the time has been both IE8 & Chrome. All IP's geolocated to Columbia, which makes it seem like a local issue, but we've been unable to replicate it.

    Ideas??

  • Zac
    Zac over 13 years
    Yes. I could also do it in the service. I am more curious about why & where the space is coming from.