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

  • SEARCH
  • Home
  • 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 3694118
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T04:27:30+00:00 2026-05-19T04:27:30+00:00

Currently i try to create some of my database export work more automated and

  • 0

Currently i try to create some of my database export work more automated and i decided to go with exporting data from MySql database to .doc file in php.

So im doing some database work and store complete html to a $str variable and then write/make new file:

$fp = fopen($file, ‘w+’);
fwrite($fp,$str);
fclose($fp);

The problem here is not creating .doc file, but when i download and view that .doc file it’s not in UTF-8 it’s in unicode.

  • 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-05-19T04:27:31+00:00Added an answer on May 19, 2026 at 4:27 am

    You do realize that giving a file a .doc extension doesn’t make it a Word document?

    Anyway, if your $str and HTML was encoded in UTF-8, so should be the downloaded file. Otherwise send it with an appropriate

    header("Content-Type: text/html; charset=UTF-8");
    

    It cannot reasonably be “in unicode”. You need to explain what that means. It’s certainly not autoconverted from UTF-8 to UCS-4 (any of the 4-byte raw unicode representations).

    However you could include the UTF-8 BOM to make it certain:

    fwrite($fp, pack("HHH", 0xEF, 0xBB, 0xBF));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I made some CMS in PHP which manipulates with data from MySQL. In my
I am currently try to retrieve a latitude and longitude value from a location.
Im currently facing the problem that when i try to set focus on some
I took over some old php application with MySQL as database. Inside the database,
Greetings, I am currently exploring some extreme programming and try to stick as much
I am trying to retrieve data from MySQL for a flash application via PHP,
I am having a bit of a problem with some mysql. I will try
I'm currently facing a performance problem with creating POCO objects from my database. I'm
I am currently selecting a large list of rows from a database using pyodbc.
procedure TMainForm.FormDestroy(Sender: TObject); var Registry: TRegistry; begin Registry := TRegistry.Create; try Registry.RootKey := HKEY_CURRENT_USER;

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.