简体   繁体   中英

Character encoding php and excel

First of all, sorry for my English :p

I want to upload an excel file (.xlsx) with names through my web. I upload and save the data correctly in my database, but when I show that data on my website the names like João or André are shown like: Jo o and Andr .

The collation in that table is utf_8_general_ci, and that names are shown like Joã£o and Andrã©.

According to the function mb_detect_encoding(), that names in the excel file are utf-8.

I tried to convert the names to utf-8 with utf8_encode() and mb_convert_encoding(), I tried to save the excel file like utf-8, I tried to save the excel file like ISO-8859-15, I tried to paste the names to notepad and save them like utf-8 and copy to my excel...I have tried many things and none has worked for me!.

I can't covert the excel file to .csv because it has to be an Excel Workbook, I'm saying it because I read that it could be a solution.

I have run out of ideas...

UPDATE: It's very strange because in localhost doesn't work, but when I upload it to the server the characters are displayed correctly

If mb_detect_encoding() is TRUE for 'UTF-8' then you only have to specify the character encoding in your HTML meta tag. Then your browser knows how to decode and display the data.

<meta charset="UTF-8">

https://www.w3schools.com/html/html_charset.asp

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