Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9007101
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T01:35:45+00:00 2026-06-16T01:35:45+00:00

I am generating a CSV file with PHP and saving it on the hard

  • 0

I am generating a CSV file with PHP and saving it on the hard disk (I do not want a download). The database charset is utf8_general_ci and there are chars in there like the degrees sign (°), which show up perfectly in PHPmyadmin. These chars need to be saved in the CSV file. Everything I do is in UTF-8, but the file gets saved with the encoding ISO-8859-1. If I start using the utf8_encode function, other chars show up (Â) when I convert it back to UTF-8 in excel or any other text editor. I do not know what is going wrong and I have spent hours to track it down, without success.

I have tried SET NAMES utf8 just to be sure it is UTF-8, but that just causes more strange characters and no UTF-8 encoding. Using MySQLi’s set_charset does the same. With the header as Content-type:text/html;charset=UTF-8 the CSV still does not have utf-8 as default encoding, nor with any of these combinations.

Some code:

header("Content-type:text/html;charset=UTF-8");
$rMysqli = new mysqli("localhost", "user", "pass", "database");
$rCSV = fopen("test_".time().".csv", 'w');

$aCSVdata = array($var1, $var2, $var3);
fputcsv($rCSV, $aCSVdata, ",", "\"");

fclose($rCSV);

That is pretty much all is happening. Just normal CSV data, only with special chars such as ° and Ø.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T01:35:47+00:00Added an answer on June 16, 2026 at 1:35 am

    …long story of the comments short…

    Microsoft Office is the worst when it comes to encodings. It notoriously sucks at it.

    (I.e. everything was fine except Excel.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am generating a CSV file containing data from a MYSQL database. There are
I am generating a simple csv file using php. The file contains some user's
I'm generating a csv file using php, now some columns contain a paragraph with
I'm generating the csv file with the following header commands: header(Content-type: text/csv; charset=utf-8; encoding=utf-8);
I am using C++ and I am generating a csv file to report some
Im generating a file to present to the user for download, but the server
I am generating a csv download from my web server and to be safe,
I am generating a CSV file from Ruby. The problem is a column string
I'm generating a CSV file from the following code public ActionResult Index() { var
I have an XSL file that I am generating from CSV from and Object

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.