Encoding Selectize是否正在插入?数据值属性中的字符
我正在使用selectize.js建立比利时所有城市的下拉列表Encoding Selectize是否正在插入?数据值属性中的字符,encoding,utf-8,character-encoding,selectize.js,Encoding,Utf 8,Character Encoding,Selectize.js,我正在使用selectize.js建立比利时所有城市的下拉列表 var cityselect = $('.city-select'); if (cityselect.length) { $('.city-select').selectize({ create: false, sortField: { field: 'text', direction: 'asc'
var cityselect = $('.city-select');
if (cityselect.length) {
$('.city-select').selectize({
create: false,
sortField: {
field: 'text',
direction: 'asc'
},
dropdownParent: 'body',
plugins: ['remove_button']
});
}
我创建selectize字段如下:
<div class="form-group">
<label for="city"><?=lang("register_volunteer_select_city_or_commune")?></label>
<select id="city" class="city-select" name="city" autocomplete="new-password" required data-validation-required-message="<?=lang("register_volunteer_select_city_or_commune_validation")?>">
<option value="" selected><?=lang("register_volunteer_select_city_or_commune")?></option>
<?php
foreach ($citiesbe as $city) {
if ($this->currentLanguage == 'fr') {
$cityName = $city->name_fr;
} else {
$cityName = $city->name_nl;
}
$key = strtolower($cityName) . "," . $city->zip_code;
echo "<option value=\"$key\"> $cityName ($city->zip_code)</option>";
}
?>
</select>
<div class="help-block font-small-3"></div>
</div>
然后在我的selectize中,我可以选择Léglise,它看起来很棒,但是当我检查元素时,我会注意到数据值设置为以下值:
<div data-value="l�glise,6860" class="item"> Léglise (6860)</div>
Léglise(6860)
因为它插入了特殊字符(本例中为é)作为?它通过POST变量将其作为?因此它会产生很多错误
我该如何处理这个问题
我已将我的数据库字符集和排序规则设置为utf8mb4,通过PHP与数据库的连接也设置为utf8mb4,并且我的文档包含一行字符集:
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
我完全没有主意了,他在这里讨论如何解决这个问题 您尝试过使用mb_strtolower()吗 PHP5与UTF-8不兼容,不能处理多字节字符,因此仍然需要使用mb扩展
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
$b = mb_strtolower($a);
echo $b;