View Full Version : Special Character Issue

20 Dec 2011, 10:58 PM
Hi All ,
if i save this symbol in my grid , its saving but showing some extra symbol ¿ . How can i avoid this . Please suggest me how can i reject junks .

21 Dec 2011, 12:37 AM
The symbol is Unicode character U+00BF. In UTF-8 that corresponds to the byte-pair C2 BF.

In ISO-8859-1 (Latin 1) the symbol is represented by the single byte BF. The byte C2 corresponds to .

So if we encode the character as UTF-8 bytes we get C2 BF. If we decode those same bytes as ISO-8859-1 we get ¿.

Exactly which part of your app is making this mistake is difficult to say. The most common source of problems is GET requests. The problems occur because there is no standard character encoding used for URL encoding the request parameters. JavaScript's encodeURIComponent function will always use UTF-8, so:

console.log(encodeURIComponent('')); // logs '%C2%BF'

If your server then interprets this as ISO-8859-1 (which Java servers like Tomcat often do by default) then it will decode to ¿. Figuring out how to configure your server correctly is beyond the scope of this forum but a quick bit of Googling should help.

If you include parameters in the POST body of a request then there is a standard encoding: everything uses UTF-8. On a number of projects where I couldn't control the encoding on the server I instead switched my requests to POST requests and it solved the problem. If you're saving data then you should be using POST instead of GET anyway.

Of course it may be nothing to do with the request parameters, it's possible the encoding issue happens elsewhere in your application.