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

后端 未结 8 734
自闭症患者
自闭症患者 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:20

    These special characters generally appear due to the the extensions. If we provide a meta tag with charset=utf-8 we can eliminate them by adding:

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    

    to your meta tags

    0 讨论(0)
  • 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

    0 讨论(0)
提交回复
热议问题