utf-8的问题 [英] Problem with utf-8

查看:148
本文介绍了utf-8的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个问题utf-8。我使用框架Codeigniter。对于客户端,我必须
将CSV文件转换为数据库。但是当我通过一个查询添加数据到数据库
是一个问题。有些字符不工作。例如这个词:Eén。当我添加这个词在PhpMyadmin,是对的。

I have a problem with utf-8. I use the framework Codeigniter. For a client i have to convert a CSV file to a database. But when i add the data trough a query to the database the is a problem. Some characters doesn,t work. For example this word: Eén. When i add this word at PhpMyadmin, it's right.

当我尝试trought Codeigniter查询,它不。
我的数据库在Utf-8上。 Codeigniter配置是utf-8。数据库配置在utf-8上。

When i try trought Codeigniter query, it doesn't. My database stands on Utf-8. The Codeigniter config is utf-8. The database config is on utf-8.

以下是查询:

 $query = "INSERT INTO lds_leerdoel(id,leerdoel,kind_omschrijving,cito,groep_id,OCW,opbouw,
kerngebied_id,jaar_maand,KVH,craats,refnivo,toelichting,auteur)
VALUES
(
'".$this->db->escape_str($id)."',
'".$leerdoel."',
'".$this->db->escape_str($kind_omschrijving)."',
'".$this->db->escape_str($cito)."',
'".$this->db->escape_str($groep_id)."',
'".$this->db->escape_str($OCW)."',
'".$this->db->escape_str($opbouw)."',
'".$this->db->escape_str($kerngebied_id)."',
'".$this->db->escape_str($jaar_maand)."',
'".$this->db->escape_str($KVH)."',
'".$this->db->escape_str($craats)."',
'".$this->db->escape_str($refnivo)."',
'".$this->db->escape_str($toelichting)."',
'".$this->db->escape_str($auteur)."'
)";

$this->db->query($query);

问题是字段leerdoel。有人解决。非常感谢你!

The problem is the field leerdoel. Does somebody a solution. Thank you verry much!!

问候,
Jelle

Greetings, Jelle

推荐答案

不应该使用国家字符串字面量吗? http://dev.mysql.com/doc/refman/5.0 /en/charset-national.html

Shouldn't you use a national character string literal? http://dev.mysql.com/doc/refman/5.0/en/charset-national.html

意思是:

 $query = "INSERT INTO lds_leerdoel(id,leerdoel,kind_omschrijving,cito,groep_id,OCW,opbouw,
kerngebied_id,jaar_maand,KVH,craats,refnivo,toelichting,auteur)
VALUES
(
'".$this->db->escape_str($id)."',
N'".$leerdoel."',
-- rest of query omitted

这篇关于utf-8的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆