I have a web app using Java HttpServer, jQuery/html, it deals with special symbols like : ♤ ♠ ♧
The app works fine in Firefox and Chrome, but when I use IE, it displayed the symbols as : ? ? ?
My jQuery code looks like this :
$(document).on('click','#Save',function()
{
var buttonData='';
$('button[id^=\"Current_\"]').each(function() { buttonData+=$(this).text()+' ' });
$.get('My_App?New_Data='+buttonData,function(responseText)
{
$('#Save_div').html(responseText);
});
});
My HttpHandler
looks like this :
public void handle(HttpExchange exchange)
{
OutputStream responseBody=exchange.getResponseBody();
String requestMethod=exchange.getRequestMethod(),requestPath=exchange.getRequestURI().getPath(),New_Data;
LinkedHashMap<String,String> params=queryToMap(exchange.getRequestURI().getRawQuery());
try
{
New_Data=(params.get("New_Data")==null?null:URLDecoder.decode(params.get("New_Data"),"utf-8"));
Headers responseHeaders=exchange.getResponseHeaders();
responseHeaders.set("Content-Type","text/html;charset=utf-8");
exchange.sendResponseHeaders(200,0);
responseText=New_Data;
responseBody.write(responseText.getBytes());
}
...
What can I do to make IE display the special symbols like the other 2 browsers ?
Edit : My IE version is :11.0.96
After some research I've found the answer.
Use encodeURIComponent() to encode the text with specials symbols then send it to the server, it worked as expected.