如何不使用htmlenties()转换某些符号


How not to not to convert certain symbols with htmlentities()?

如何"请求"htmlentities()不转换某些符号?例如,

php、

<?php echo htmlentities(file_get_contents('fonts.css'),ENT_QUOTES);?>

fonts.css,

@font-face {
    font-family: 'ChunkFiveRoman';
    src: url('chunkfive-webfont.eot'); /* EOT file for IE */
    src: local('☺'), url('chunkfive-webfont.ttf') format('truetype'); /* TTF file for CSS3 browsers */
}

结果,

@font-face {
    font-family: 'ChunkFiveRoman';
    src: url('chunkfive-webfont.eot'); /* EOT file for IE */
    src: local('�'), url('chunkfive-webfont.ttf') format('truetype'); /* TTF file for CSS3 browsers */
}

我想保留☺'照原样,但不要将其转换为"�º’。

有可能吗?

使用htmlentities的第三个参数。它指定了字符集:

<?php echo htmlentities(file_get_contents('fonts.css'),ENT_QUOTES,"UTF-8");?>

这样可以避免将微笑符号转换为拉丁语1字节的等效符号。(这就是它的样子。)