【问题标题】:Codeigniter xml_from_result output with strange characters "´╗┐´╗┐"Codeigniter xml_from_result 输出带有奇怪的字符“´╗┐´╗┐”
【发布时间】:2013-01-19 04:38:51
【问题描述】:

我一直在使用 codeigniter 框架,因为 任何输出我都有这个字符“´╗┐´╗┐”

//config.php

$config['charset'] = 'UTF-8';

我的印刷品 http://web.wipix.com.br/Capturar.PNG

/* Model */
public function AllVotos()
{
$this->load->dbutil();          
        
$select = $this->db->query("SELECT SUM(voto = '0') as insatisfatorio,   SUM(voto = '1') as bom, SUM(voto = '2') as excelente FROM qr_wiplay_participacoes ");

$config = array (
            'root'    => 'root',
            'element' => 'element',
            'newline' => "\n",
            'tab'     => "\t"
           );

return $this->dbutil->xml_from_result($select, $config);
}



/* Controller */

public function AllVotos(){

$xml = $this->home_model->AllVotos();
    
$this->output->set_content_type('text/xml');

$this->output->set_output($xml); 


}

【问题讨论】:

  • 当我在带有 BOM 的 utf-8 文件上执行 type a.xml 时得到 ´╗┐<root></root>(也使用 Windows cmd),而当我在没有 BOM 的文件中执行相同操作时只有 <root></root>。所以´╗┐ 必须是命令行代码页中的 BOM。不过,我不知道您为什么会两次获得这些符号。
  • 请提供该 XML 字符串的十六进制转储,请参阅 stackoverflow.com/a/1057579/367456 - 而不是屏幕截图,就像您问题中的格式化文本一样。
  • 感谢 cmets。我的问题不在“字符串”中,而是在页面输出中,当生成 xml 时没有出现奇怪的字符,如果我的页面输出为空,我只看到当我在 windows cmd 中执行“type allvotos.xml”时,奇怪的字符也会出现.我认为这与 Codeigniter 框架有关

标签: php xml codeigniter character-encoding


【解决方案1】:

这是因为文件带有 BOM 签名 使用您的编辑器删除签名 织梦者

Modify => Properties page => Title / Encoding => Clear => Include Unicode Signature (BOM)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-04-23
    • 1970-01-01
    • 1970-01-01
    • 2018-07-22
    • 2018-10-29
    • 2019-07-27
    • 1970-01-01
    相关资源
    最近更新 更多