I have facing issue in displaying German Umlaut characters in HTML page of angular2 application. My backend services are in java and it returns json String.
This is the response of the post request which is shown in network tab. and it shows ü character properly .
but if i console the data from below snippet, it shows � both in HTML ui and console .
getStackById(project: string, stackId: string, ibsessionid: string) {
var headers = new Headers();
headers.append('Content-Type', 'application/x-www-form-urlencoded');
return this.http.post('http://' + this.ip + ':' + this.port + '/IBPublicationBuilder/MiddlewareServlet', 'project=' + project + '&stackid=' + stackId + '&ibsessionid=' + ibsessionid + '&method=getStackById', {
withCredentials: true, headers: headers
}).map(
(res: Response) => {
console.log(res);
return res.json()}
);
}
Solved the issue with the below solution.
Added
headers.append('Content-Type', 'application/x-www-form-urlencoded; charset=utf-8');
In the header and also Changed the server side. As I mentioned my services were in java . Added
response.setContentType("text/html; charset=UTF-8");
response.setCharacterEncoding("UTF-8");
to my my response object.