°F- $.get("http://blah.com/go",{'TU':$('#a').text()}); - The IIS server logs show the...">

HTML coding additional degree symbol

  • <div id="a">°F</div>
  • $.get("http://blah.com/go",{'TU':$('#a').text()});
  • The IIS server logs show the following parameters:
    99.5% of the time: TU =% C2% B0F
    0.5% of the time: TU =% C2% B0 + F Server
  • subsequently crashes because he does not know what “F” is. Admittedly, one of the drawbacks is that we clear the text from the DOM and send it to our server. This is where I suspect there is a problem, but I would like to know more.

Additional Information: 0.5% of the time was both IE8 and Chrome. All IP addresses are tied to Columbia, which makes it look like a local problem, but we could not reproduce it.

Ideas ??

+5
source share
2 answers

So, the problem is that sometimes there is a space between °and F, is this space converted to +, and the server does not accept it? If so, why not split the space before sending?

$.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')});
+1
source

How does text fit in a div? You should output this before checking the server value. I do not think you have a different encoding of the same text. This is probably due to how you place it on the page.

Also try setting the page encoding on the server before you get the query string, it is possible that different browsers use a different encoding. UTF-8 is the encoding proposed by w3.org. In Java, you need to make sure that you set the encoding before any calls in order to read anything from the client.

0

All Articles