Avatar of cfpdev
cfpdev
 asked on

Browsers open PHP generated tab delimited file with quicktime, instead of inline inside the browser

We are creating various CSV files with PHP. We have one CSV file, that uses iconv encoding in order to display Japanese characters, this file is also tab delimited, and not comma delimited, but is still saved with a '.csv' extension. This doesn't bother excel at all. Problem is, when we try to open this CSV file via a url, inline in the browser, the browser tries to open it using Quicktime.

This happens regardless whether the file is comma or tab delimited, it seems that the problem is the the japanese character encoding. I include a snippet of what our encoding code looks like, nothing special actually.

I have tried saving it as a txt file, but then it looses its Japanese character encoding.

Does anyone know how we can solve this?


$string= chr(255).chr(254).iconv ( 'UTF-8', 'UTF-16LE', "some japanese characters");

Open in new window

PHP

Avatar of undefined
Last Comment
cfpdev

8/22/2022 - Mon
hernst42

Are you sending the correct headers via your php-script?

header('Content-Type: text/csv');
ASKER CERTIFIED SOLUTION
cfpdev

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
cfpdev

ASKER
Thanks hernst42, we were using the correct headers.
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck