codeigniter,标准html与表单助手输出的utf8(希腊语)字符的差异

时间:2013-03-16 05:09:39

标签: mysql codeigniter encoding codeigniter-form-helper

此:

<td><?php echo form_input('post_title',set_value('post_title',$post->post_title)); ?></td>

会在页面上显示希腊字符(或拉丁字符以外的任何字符)和

此:

<p>Title: <input name="post_title" type="text" value="<?php echo $post->post_title ?>"/></p>

将正确显示。

Web page

我的MySQL类型是MyISAM和utf8_latin_ci整理。

尝试从phpMyAdmin浏览也给了我&amp; #xxx ...

phpMyAdmin

错误在哪里?

P.S从codeigniter手册关于表单助手方法

  

并将始终根据charset添加属性accept-charset   配置文件中的值。

我的配置文件设置为

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

更新:我的页面标题:

GET /posts/editpost/23 HTTP/1.1
Host: my.xxx.com
Connection: keep-alive
Cache-Control: max-age=0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.22 (KHTML, like Gecko) Chrome/25.0.1364.152 Safari/537.22
Referer: http://my.xxx.com/posts
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3

2 个答案:

答案 0 :(得分:1)

这是设置字符的一般问题。请保持字符集编码在HTML文件,CI配置文件中的每个位置都相同,并且在数据库中最重要。创建数据库时,请选择UTF-8或任何其他适合您语言的数据库(对于大多数UTF-8语言都适用)。或者您也可以为单个表更改它。请进行这些更改,您将获得正确的希腊语言。 谢谢

答案 1 :(得分:0)

尝试使用这三个Text辅助函数:

ascii_to_entities()

entities_to_ascii()

convert_accented_characters()

取决于您如何将其保存在数据库中

他们来自CI的文本助手

http://ellislab.com/codeigniter/user-guide/helpers/text_helper.html

也不要忘记加载此帮助程序;)