J'ai ce code qui fonctionne très bien en dehors de Joomla, mais une fois que je l'ai mis dans un module Joomla, il ne code pas correctement. Voir
"Cura�ao - - converti: Cura? Ao"
par exemple. Ce devrait être
"Cura�ao - - converti: Curaçao"
lorsqu'il est codé correctement.
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<?php
error_reporting(E_ERROR);
header('Content-Type: text/html; charset=utf-8' );
$includes_url = $_SERVER['DOCUMENT_ROOT'] . "/Joomla33/_Leagues/_includes/";
ini_set('default_charset', 'utf-8');
include_once($includes_url. "php/OpenDB.php");
$query = "SELECT * FROM chasiv_timezones.country ORDER BY country_name ASC";
$result = mysqli_query($conn, $query);
?>
Country:<select id='country' name='country'>
<option value=''>-- Select --</option>
<?php
while($data = mysqli_fetch_assoc($result)) {
echo $name = mb_convert_encoding($data['country_name'],'utf8');
if($data['country_code'] == $row['country']) { $sel = " selected"; } else { $sel = ""; }
?>
<option value="<?php echo $data['country_code']; ?>" <?php echo $sel; ?>><?php echo $name; ?></option>
<?php
}
?>
</select>
<?php
$query = "SELECT * FROM chasiv_timezones.country ORDER BY country_name ASC";
$result = mysqli_query($conn, $query);
if(!$result) {
exit("Unable to connect to database to get timezone countries. SQL:" . $query);
}
echo "<br />";
mysqli_set_charset($conn, 'utf8mb4');
while($data = mysqli_fetch_assoc($result)) {
echo $data['country_name'] . ' - ' . mb_check_encoding($data['country_name'],'utf8');
if(!mb_check_encoding($data['country_name'],'utf8')) {
echo " - converted:" . mb_convert_encoding($data['country_name'],'utf8') . '<Br />';
} else {
echo "<br />";
}
}
?>
J'ai trouvé le problème. Cette ligne:
mysqli_set_charset($conn, 'utf8mb4');
Doit être avant mysqli_query et non après.