Search code examples
mysqlangularjsspecial-characters

AngularJS not showing accented characters


In my MySQL database I have international strings with accented characters, such as ñ or é.

I can retrieve values from DB with Angular services and show then on the Views through Controllers, but whenever there is an accented character in a string, the whole string does not show up.

I have tried with $sce, with ng-bind-html, but always the same result. Strings with accented characters do not show.

Am I missing something?


Solution

  • Ok, found the issue. It was not related to Angular but to PHP reading the response from the MySQL server in a wrong character set.

    In PHP, after opening a connection $mysqli, you should tell it to use the same CHARSET/COLLATION as your database/table is using:

    $mysqli->set_charset('utf8');
    

    Then special chars will be interpreted perfectly.