I have 2 cases here:
My Database contains lots of info which I want to fetch to the page, some of these info are name which contain non-ascii chars like Uwe Rü
The �
means that you used a character which can't be represented properly.
Somewhere between the server and the client, you need to encode the string data properly. I don't know how you transfer the data from the server to the client (generate JavaScript, AJAX, GET requests), it's hard to say how to fix this.
But what you need to do: For every step, you must make sure that you know what the current encoding of the data is and what the recipient expects.
For example if you generate inline JavaScript in a HTML page, then the string value must be encoded with the same encoding as the page (iso-8859-1
). If you use AJAX, then usually you have to use UTF-8
.