Why is this the extended ascii character (â, é, etc) getting replaced with <?> characters?

后端 未结 8 794
自闭症患者
自闭症患者 2021-01-06 12:00

Why is this the extended ascii character (â, é, etc) getting replaced with characters?

I attached a pic... but I am using PHP to pull the data from MySQL,

8条回答
  •  Happy的楠姐
    2021-01-06 12:17

    There are two transmission encodings, PHP<->browser and Mysql<->PHP, and they need to be consistent with each other. Setting up the encoding for Mysql<->PHP is dealt with in the answers to the questions below:

    • Special characters in PHP / MySQL
    • How to make MySQL handle UTF-8 properly
    • php mysql character set: storing html of international content

    The quick answer is "SET NAMES UTF8".

    The slow answer is to read the articles recommended in the other answers - it's a lot better to understand what's going on and make one precise change than to apply trial and error until things seem to work. This isn't just a cosmetic UI issue, bad encoding configurations can mess up your data very badly. Think about the Simpsons episode where Lisa gets chewing gum in her hair, which Marge tries to get out by putting peanut butter on.

提交回复
热议问题