简体   繁体   中英

problem with chinese character

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 character, 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

在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_ ).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM