Why non-ascii chars are displayed as weird symbols?

后端 未结 3 1382
盖世英雄少女心
盖世英雄少女心 2021-01-20 11:44

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ü

3条回答
  •  不思量自难忘°
    2021-01-20 12:37

    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.

提交回复
热议问题