| | |
Porblem in UTF-8 support on CSV/EXCEL
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved
![]() |
Hi,
First Problem:
I have a PHP script that export CSV with Japanese text, for example I download the CSV on the website then save to desktop of my computer and Open it on NOTEPAD... that works fine I could still see all the japanese text OK with no problem, but if I open the CSV file in Microsoft EXCEL, all the japanese text are busted and no longer readable.
Do you know a solution for this, how could I make it work OK on MS Excel, because the user want it to view the CSV file in Excel.
And my second Problem is:
I have another PHP script that export data with Japanese text from database to MS Excel, if I type the Japanese text on the script it works fine but if the text came from database, my problem starts because when i Download and open it in MS Excel the japanese text That I type directly in the script as a header of the excel file is OK but the contents in japanese text populated from the database is not readable in Japanese form....
Do you have any solution for my problem....
Thanks
First Problem:
I have a PHP script that export CSV with Japanese text, for example I download the CSV on the website then save to desktop of my computer and Open it on NOTEPAD... that works fine I could still see all the japanese text OK with no problem, but if I open the CSV file in Microsoft EXCEL, all the japanese text are busted and no longer readable.
Do you know a solution for this, how could I make it work OK on MS Excel, because the user want it to view the CSV file in Excel.
And my second Problem is:
I have another PHP script that export data with Japanese text from database to MS Excel, if I type the Japanese text on the script it works fine but if the text came from database, my problem starts because when i Download and open it in MS Excel the japanese text That I type directly in the script as a header of the excel file is OK but the contents in japanese text populated from the database is not readable in Japanese form....
Do you have any solution for my problem....
Thanks
I have the same problems with encoding in a different content - XML files.
For your prob..
Does excel support utf-8 fully?
Question I'm asking myself, how does excel determine encoding?
When saving to the database, is the database data stored as UTF-8?
PHP functions are also non-utf8 aware. For example: strlen() on a UTF-8 string would return the number of bytes in the string, not the number of UTF-8 chars which would be less since a single char is encoded in multiple bytes..
Does your code use some PHP string functions?
For your prob..
Does excel support utf-8 fully?
Question I'm asking myself, how does excel determine encoding?
When saving to the database, is the database data stored as UTF-8?
PHP functions are also non-utf8 aware. For example: strlen() on a UTF-8 string would return the number of bytes in the string, not the number of UTF-8 chars which would be less since a single char is encoded in multiple bytes..
Does your code use some PHP string functions?
www.fijiwebdesign.com - web design and development and fun
Cpanel Email - Let users Register email accounts on your website upon registration
Ajax Chat - Fully browser based chat!
Cpanel Email - Let users Register email accounts on your website upon registration
Ajax Chat - Fully browser based chat!
Hi, thanks for the reply. I already found a solution on my problem, I use this kind of php function to solve my problem this solve all of my encoding problem....
thanks
$str = mb_convert_encoding($str, "SJIS","UTF-8");
thanks
Awesome.
Just a note: in order to use the function b_convert_encoding, your php installation needs to have the mb_string extension loaded. Not all PHP installations will have this.
I believe there is a sourceforge.net project however that has a mirror of the mb_string functions in PHP.
This will allow you to use the mb_string functions on "any" PHP installation.
Just a note: in order to use the function b_convert_encoding, your php installation needs to have the mb_string extension loaded. Not all PHP installations will have this.
I believe there is a sourceforge.net project however that has a mirror of the mb_string functions in PHP.
This will allow you to use the mb_string functions on "any" PHP installation.
www.fijiwebdesign.com - web design and development and fun
Cpanel Email - Let users Register email accounts on your website upon registration
Ajax Chat - Fully browser based chat!
Cpanel Email - Let users Register email accounts on your website upon registration
Ajax Chat - Fully browser based chat!
•
•
Join Date: Jun 2009
Posts: 1
Reputation:
Solved Threads: 0
Hi Guys,
It seems like everyone is having this issue. This is very common problem and i have been looking for its solution for a long time too. I have't tried the mb_... function and i am not sure if this will help for all languages but here is something i have found and have tested it to make sure it works for almost all languages.
This is problem with Excel NOT the data format that is exported. Here are the steps
1- download the exported CSV/XLS file from your website.
2- Open Excel 2007
3- Open a new file
4- Click the Data Menu option
5- Click "From Text" button
6- Select the file you downloaded
7- Make sure "Delimited" is selected and Press Next
8- Check the delimiter characters that you know are in your file like Comma or Tab or whatever is in your case. You can select more than one
9- Proceed to Next Step and Finich
10- Your excel file will be ready with all you data displayed correctly
I hope that helps someone who has been frustrated on this.
Regards
Nauman
It seems like everyone is having this issue. This is very common problem and i have been looking for its solution for a long time too. I have't tried the mb_... function and i am not sure if this will help for all languages but here is something i have found and have tested it to make sure it works for almost all languages.
This is problem with Excel NOT the data format that is exported. Here are the steps
1- download the exported CSV/XLS file from your website.
2- Open Excel 2007
3- Open a new file
4- Click the Data Menu option
5- Click "From Text" button
6- Select the file you downloaded
7- Make sure "Delimited" is selected and Press Next
8- Check the delimiter characters that you know are in your file like Comma or Tab or whatever is in your case. You can select more than one
9- Proceed to Next Step and Finich
10- Your excel file will be ready with all you data displayed correctly
I hope that helps someone who has been frustrated on this.
Regards
Nauman
![]() |
Similar Threads
- Websites content extraction team (Post your Resume)
- 1 .Exporting data from Dataset to XLl sheet in VB.net Windows Application &vice versa (VB.NET)
- how to read CSV file in java (Java)
- win32::ole and excel question (Perl)
- Why are there so many languages? (Computer Science)
- Help in understanding Adwords conversion tracking report (Search Engine Optimization)
Other Threads in the PHP Forum
- Previous Thread: making sure a textbox starts with http:// ?
- Next Thread: help needed
| Thread Tools | Search this Thread |
# .htaccess 5.2.10 access alexa apache api array beginner broken cakephp checkbox class clean clients cms code convert cron curl database date directory display dissertation dropdown dynamic echo$_get[x]changingitintovariable... email encode error fairness file folder form forms function functions google hack href htaccess html htmlspecialchars image include indentedsubcategory ip javascript joomla legislation limit link local login mail memberships menu methods multiple multipletables mysql mysqlquery network newsletters oop open passwords paypal pdf persist php provider query radio random redirect remote script search secure server sessions simple sockets source space spam sql system table tutorial upload url user variable video voteup web youtube






