阿拉伯文输出php mysql utf-8转换问题 [英] Arabic text output php mysql utf-8 conversion issue

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

问题描述

我从Oracle数据库将数据导入到MySQL表。



我已将我的MySQL表字符集设置为 utf8_general_ci ,并将数据库和表名称与字段列值设置为 utf-8



我获取结果,它打印像,这是与? sign

 مرحباالعال  -  5 

我的utf值列在Ù...ØØØبااÙعاÙÙ



当我将此字符串与Oracle字符串进行比较时,它显示正确的值 - Oracle数据库的完全副本, p>

我已经使用utf-8设置了我的html meta

  ; meta http-equiv =Content-Typecontent =text / html; charset = utf-8> 

如果我设置mysql查询如下,它显示垃圾字符:

  mysql_query(SET NAMES utf8;); 
mysql_query(SET CHARACTER_SET utf8;);

跟踪在堆栈和其他网站上发现的一切,但仍然出现错误。

$

请帮助!

解决方案

http://en.wikipedia.org/wiki/Byte_order_mark\"> BOM ?如果没有,试试看。 UTF-8 BOM的潜在问题






进一步尝试使用单引号和没有SET CHARACTER_SET的'utf-8'

  mysql_query(SET NAMES'utf8'); 

并在html文档标题中使用charset utf-8:

  header(content-type:text / html; charset = utf-8); 


I'm importing data from Oracle database to MySQL tables.

I have set my MySQL table charset as utf8_general_ci and database and table name with field column value set as utf-8 as well.

Now, When I fetch the result, it prints like, which is with ? sign:

مرحبا العال� - 5

I have my utf value in column is مرحبا العالÙ

When I compare this string with Oracle string, it shows proper value - exact copy of Oracle database and there it shows perfect string in Arabic.

I have set my html meta with utf-8 as well

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" >

If I set mysql query as below, it shows junk characters:

mysql_query("SET NAMES utf8;");
mysql_query("SET CHARACTER_SET utf8;");

Followed everything possible found over stack and other sites, and still getting an error.

Please help !

解决方案

Did you save the php-file without BOM? If not, try it. Potential issues with the UTF-8 BOM


Further try with 'utf-8' using single quotes and without SET CHARACTER_SET

mysql_query("SET NAMES 'utf8'");

and with charset utf-8 in the html-document header:

header("content-type: text/html; charset=utf-8");

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

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