How can I ‘ask’ htmlentities() not to convert certain symbols? For instance,
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 */
}
result,
@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 */
}
I want to keep ‘☺’ as it is but not to convert it into ‘â�º’.
Is it possible?
Use the third parameter of
htmlentities. It specifies the charset:This avoids the smiley to be converted into Latin-1 byte equivalents. (Which is what it looks like.)