When trying to make a JS chat I got stuck in a problem with accented charactes. Their names are gotten from Mongodb with PHP and then sent to the view and js like that:
$name = $user['id']['info']['first_name']; //Éric
$c = mb_detect_encoding($name, mb_detect_order(), true);
$name = iconv($c,'ASCII//TRANSLIT', $name);
var username = "<?php echo $name; ?>" // Displays ric
I tried sugestions from this question, mostly works only if string set mannualy, like:
$name = 'á|â|à|ä';
...
var username = "<?php echo $name; ?>" // Displays a|a|a|a
Am I missing something?