Problems displaying French accented characters in UTF-8

前端 未结 4 1853
清酒与你
清酒与你 2021-01-12 07:14

I\'m working on a French language site built in CakePHP. I have tried multiple functions to try and convert the text into UTF-8 and display properly, but have had no succes

4条回答
  •  萌比男神i
    2021-01-12 07:31

    In case this helps anyone using PHP Classes.

    My solution was to set Character Encoding to my Connection.

    //connect to MySQL and select DB
    public function open_connection() {
        $this->connection = new mysqli( DB_SERVER, DB_USER, DB_PASS, DB_NAME );
        if ( !$this->connection ) {
            die( "Database connection failed: " . mysqli_error() );
        }
        mysqli_set_charset($this->connection,"utf8");
    }
    

提交回复
热议问题