htmlentities无法使用°(°)

时间:2014-08-26 12:14:08

标签: php

遇到一些麻烦但没有得到它的位置,我想在DB中将°char保存为°

//$_POST['group'] = "1° BF"

$group = htmlentities($_POST['group'], ENT_QUOTES, "UTF-8");

//$group should be "1° BF" but still shows as "1° BF"

文档字符集也被定义为UTF-8

1 个答案:

答案 0 :(得分:0)

好吧,我想我终于明白了。如上所述,我实际上在DB中存储为°,我需要使所有字符都相同,因为我混合了°,º,ª(都是从一些古老的DBF导入的)。 你怎么看待这个?

//$group = 1° BF, or 1º BF, or 1ª BF

//check var length here
$group = htmlentities($_POST['group'], ENT_QUOTES, "UTF-8");
$group = str_replace("°", "°", $group);
$group = str_replace("º", "°", $group);
$group = str_replace("ª", "°", $group);
$group = str_replace("|", "°", $group);

//$group = "1° BF", ready to go to DB.

编辑: 以下deceze sugestion