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

后端 未结 8 732
自闭症患者
自闭症患者 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条回答
  •  说谎
    说谎 (楼主)
    2021-01-06 12:21

    Simplest fix

    ini_set( 'default_charset', 'UTF-8' );
    

    this way you don't have to worry about manually sending the Content-Type header yourself.

    EDIT

    Make sure you are actually storing data as UTF-8 - sending non-UTF-8 data to the browser as UTF-8 is just as likely to cause problems as sending UTF-8 data as some other character set.

    SELECT table_collation
      FROM information_schema.`TABLES` T
     WHERE table_name=[Table Name];
    
    SELECT default_character_set_name
         , default_collation_name
      FROM information_schema.`SCHEMATA` S
     WHERE schema_name=[Schema Name];
    

    Check those values

提交回复
热议问题