Reputation: 235
I'm facing a problem with BrowserField in Blackberry, i have some HTML content that contains some characters like " ' " but when i'm trying to show this content in my BrowserField i can't display those chars it appears like this " ? " I changed BrowserField by RichTextField and i can see my characters there so i think the problem is from the BrowserField, i tried to change the encoding like this :
HttpHeaders headers = new HttpHeaders();
headers.addProperty(HttpHeaders.HEADER_CONTENT_TYPE,HttpHeaders.CONTENT_TYPE_TEXT_HTML);
headers.addProperty(HttpHeaders.HEADER_ACCEPT_CHARSET, "ISO-8859-1,utf-8;q=0.7,*;q=0.7");
config.setProperty(BrowserFieldConfig.NAVIGATION_MODE, BrowserFieldConfig.NAVIGATION_MODE_POINTER);
config.setProperty(BrowserFieldConfig.ALLOW_CS_XHR, Boolean.TRUE);
config.setProperty(BrowserFieldConfig.HTTP_HEADERS, headers);
But the problem is still there :( can you please help me Best Regards
Upvotes: 0
Views: 389
Reputation: 109613
The problem is likely due to the difference between ISO-8859-1 and its superset Cp1252 (=Windows-1252). One of the extra charactes are non-ASCII quotes as MS Word produces.
Pages sent to the browser may say they are in ISO-8859-1 (Latin-1) but in reality be in the superset Windows-1252 (Windows Latin-1). Even on a Mac it went okay in all browsers. In this case you have to change on the server side to encoding Cp1252.
response.setEncoding("Cp1252");
or
response.setContentType("text/html; charset=Windows-1252");
Of course UTF-8 does not have this problem and is international. So a viable alternative.
Upvotes: 2