简体   繁体   English

无法在IE中显示特殊字符

[英]Unable to display special characters in IE

I'm working on a site that has a basic search function to search through products with ajax and display the results along with what was searched for. 我正在一个具有基本搜索功能的网站上进行搜索,以使用ajax搜索产品并显示搜索结果。 However, for reasons beyond my understanding, if the search contains any special character (ie. é, è, ê) , the character is replaced with a box. 但是,由于超出我的理解范围的原因,如果搜索包含任何特殊字符(ie. é, è, ê) ,则该字符将替换为方框。 I can't figure out where exactly things are going wrong, and why this is only affecting IE. 我无法弄清楚到底哪里出了问题,以及为什么这只会影响IE。

The code: 编码:

<div class="aux_title"><?php echo htmlspecialchars($this->search_term); ?></div>

The site operates using joomla if that helps/changes anything. 如果有帮助/更改任何内容,则该网站将使用joomla进行操作。

Try setting your charset to UTF-8 尝试将字符集设置为UTF-8

<meta charset="utf-8">

Or another charset that better supports your languages. 或另一个更好地支持您的语言的字符集。 Charsets 字符集

I finally found an adequate solution to my peculiar problem. 我终于找到了解决我特有问题的合适方法。

<?php
    $enc = mb_detect_encoding($this->search_term, mb_detect_order(), true);

    if ($enc != 'UTF-8') {
        $this->search_term = utf8_encode($this->search_term);
    }
?>
<div class="aux_title"><?php echo htmlspecialchars($this->search_term); ?></div>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM