开发者

problem with chinese character

开发者 https://www.devze.com 2023-02-08 23:10 出处:网络
We can store Chinese character into mysql table Using this (\"meta http-equiv=\"Content-type\" value=\"text/html; charset=UTF-8\" \")

We can store Chinese character into mysql table Using this

("meta http-equiv="Content-type" value="text/html; charset=UTF-8" ")

at the top of the page and taking Chinese character through input box manually easily, it works OK and store Chinese character into mysql table like this("A#20026;A#24744; A#20026;A#24744;").

But when read Chinese char from an excel file using php and want to insert in mysqltable with php then it stores like this

("上海东渡船舶管ç†æœ‰é™å…¬å¸")

This is also working fine with the help of php header function ["header('Content-type: text/html; charset=UTF-8') ;"] without http header it is no working. But I want to store chinese char like above("A#20026;A#24744; A#20026;A#24744;") in mysql table.

Note:= Where u see "A" in code there is "ampersand" sign. If i write "ampersand" there then it will display as chinese charact开发者_运维知识库er, so here noticed.

Any one can help me ? Help should be happily. Thanks. Have a nice day...


You should retag your question from SQL to Excel. Apparently, it is not related to mysql. Problem is the part where you read Excel file in PHP. You get corrupted data from Excel file and then it is too late to do anything.

Does library you use to read Excel files understand unicode characters at all? Do PHP understand unicode or is that library at least able to send unicode characters in utf-8? I don't think so. (UTF-8 strings can work correctly in scripting environments where unicode isn't actually supported, because the program only transfers the string from user to database and vice versa.)


The characters are not stored as UTF-8 in your excel file then and have to be transcoded.

See utf8_encode


Try after the MySQL_connect :

mysql_query("SET NAMES 'utf8'");


You should first make sure, that the Database-Table and the Form, where the User enters the characters, are both UTF-8. Also notice, that many PHP-Functions don't support UTF-8. If you are using functions like htmlentities(), make sure you replace them by Multibyte-String-secure functions (mb_).

0

精彩评论

暂无评论...
验证码 换一张
取 消