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

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

问题描述

我正在将数据从 Oracle 数据库导入 MySQL 表.

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

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

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

我在列中的 utf 值是 مرØبا العالÙ

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

当我将此字符串与 Oracle 字符串进行比较时,它显示了正确的值 - Oracle 数据库的精确副本,并在那里显示了阿拉伯语的完美字符串.

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.

我也用 utf-8 设置了我的 html 元

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

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

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

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.

请帮忙!

推荐答案

你是否在没有 BOM 的情况下保存了 php 文件?如果没有,请尝试一下.UTF-8 BOM 的潜在问题

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

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

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

mysql_query("SET NAMES 'utf8'");

并在 html 文档标题中使用字符集 utf-8:

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天全站免登陆