简体   繁体   English

Codeigniter字符编码问题

[英]Codeigniter Character Encoding Issues

I have a few simple pages which have no database data, and are just statically loaded from the controller. 我有一些没有数据库数据的简单页面,只是从控制器静态加载。 I have set everything possible to UTF-8 encoding. 我已经将所有可能设置为UTF-8编码。 I have checked headers, which result to UTF-8 . 我检查了标题,结果是UTF-8 However, it still parses wrong showing these characters: . 但是,它仍然会解析显示这些字符的错误: 。

Controller : 控制器

function index(){

    $this->load->view('french/header_view');
    $this->load->view('french/homepage_view');
    $this->load->view('french/footer_view');

}    

Config File : 配置文件

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

Header View : 标题视图

<? header("Content-Type: text/html; charset=UTF-8"); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html >
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
....

Characters Used in Body View : 身体视图中使用的字符

géniales - à - époustouflant géniales - à - époustouflant

Characters generated : 生成的字符

se g niales ! seg niales!

Where have I gone wrong? 我哪里出错了? Thanks for your help! 谢谢你的帮助!

It seems that the data is not encoded in UTF-8. 似乎数据不是用UTF-8编码的。 Have you checked the encoding settings of your editor? 你检查过编辑器的编码设置了吗?

I had the same problem with Dreamweaver CS4, but I fixed it with Notepad++ (FREE!). 我在Dreamweaver CS4上遇到了同样的问题,但我用Notepad ++修复了它(免费!)。

1.- Use Notepad++ -> Format -> Convert to UTF-8 WITHOUT BOM. 1.-使用Notepad ++ - >格式 - >转换为UTF-8,无BOM。

2.- Save. 2.-保存。

3.- REVIEW again the file and correct the characters showing wrong. 3.-再次查看文件并更正显示错误的字符。

4.- Save again. 4.-再次保存。

5.- You're done. 你已经完成了。

(Also make sure in the config file in CI you have UTF8). (还要确保在CI的配置文件中有UTF8)。

For me at least it worked that way (Spanish). 对我来说,至少它是这样的(西班牙语)。

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

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