unicode和utf8数据从数据库读取到php / html

时间:2022-09-26 08:51:37

In my database i have a column of keywords. And in my column urdu language keywords is saved like this

在我的数据库中,我有一列关键字。在我的专栏中,urdu语言关键字保存为这样

(ضرورت لوڈرزکوڑا کرکٹ اٹھان...)

(ضرÙرتٓÙÚرزک'Ú'اکرکٹاٹھان...)

but when i display it in php. It gives me correct urdu keywords.

但是当我在php中显示它。它给了我正确的urdu关键字。

Today i imported more keywords from an ods format file now in my column keywords are saved like this

今天我从ods格式文件中导入了更多关键字,现在我的列关键字就像这样保存了

(پلاٹ پلاٹس کنال مرلہ مرلے کنال ٹاپ سٹی خریدوفروخت ...)

(پلاٹپلاٹسکنالمرلہمرلےکنالٹاپسٹیخریدوفروخت...)

so in order to display ods file keywords i have to run this query

所以为了显示ods文件关键字,我必须运行这个查询

mysql_query ("set character_set_results='utf8'"); 

From this query ods data display correctly but above not and when i run this query

从这个查询ods数据显示正确,但上面没有,当我运行此查询

mysql_query ("set character_set_results='unicode'"); 

above data print correctly but below not.

以上数据打印正确但不低于。

2 个解决方案

#1


1  

when connect to DB

连接到DB时

mysql_select_db($bd_base, $con); 
mysql_query('SET NAMES utf8');

Save all php files in utf-8 without boom, use notepad++ or alkepad. MS notepad save with boom and make problems.

在没有繁荣的情况下将所有php文件保存在utf-8中,使用notepad ++或alkepad。 MS记事本保存与繁荣和问题。

#2


0  

you should treat with your data by utf8 like the second option, but before this you should import your data which inserted by the default encoding to database then import again as utf8.

您应该像第二个选项一样使用utf8处理您的数据,但在此之前您应该将通过默认编码插入的数据导入数据库,然后再次导入为utf8。

#1


1  

when connect to DB

连接到DB时

mysql_select_db($bd_base, $con); 
mysql_query('SET NAMES utf8');

Save all php files in utf-8 without boom, use notepad++ or alkepad. MS notepad save with boom and make problems.

在没有繁荣的情况下将所有php文件保存在utf-8中,使用notepad ++或alkepad。 MS记事本保存与繁荣和问题。

#2


0  

you should treat with your data by utf8 like the second option, but before this you should import your data which inserted by the default encoding to database then import again as utf8.

您应该像第二个选项一样使用utf8处理您的数据,但在此之前您应该将通过默认编码插入的数据导入数据库,然后再次导入为utf8。