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 7160853
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T13:28:00+00:00 2026-05-28T13:28:00+00:00

I fetch lines of UTF-8 text from a page then dump into a file.

  • 0

I fetch lines of UTF-8 text from a page then dump into a file. The text in the original page appears fine. However, the text in the output file appears scrambled!

My attempt:

$myFile = "testFile.txt";
$fh = fopen($myFile, 'w') or die("can't open file");
$pageContent = file_get_contents("page.html");
//Here: use regex to grab the title ...
$stringData = $title."\n";
fwrite($fh, utf8_encode($stringData));
fclose($fh);

Before writing anything to the file. I saved the file as UTF-8 and i also saved it as Unicode, i still get scrambled text as:

ÊãäíÇÊí ááÌãíÚ

I’m not using PHP5

Any help will be appreciated…

  • 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-28T13:28:01+00:00Added an answer on May 28, 2026 at 1:28 pm

    Don’t use utf8_encode!

    Sorry for the shouting, it’s just misused way too often.
    Your text is already in UTF-8.* You do not need to encode it to UTF-8 again.
    utf8_encode converts Latin1 encoded text to UTF-8. Your text is not Latin1 encoded. That’s why it screws up. Just read and write the text, done. No encoding conversion or re-encoding necessary.

    * Assuming page.html is encoded in UTF-8. From what you’re saying, it seems to be.

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

Sidebar

Related Questions

I am trying to fetch data from the text file. The lines of interest
I'm trying to fetch data from a page that resides on an intranet. The
What I love about awk is you can fetch all the lines from a
I want to fetch the content of an text file and I have manage
I need to fetch HTML from Turkish webpages using Java. However, I am finding
I want to fetch <FONT COLOR=#0000ff>(insert some text here)<\/FONT> with preg_match. Lines similar to
I got a Wikipedia article and I want to fetch the first z lines
I wrote a function in Java to fetch 10 links by their IDs from
I fetch all tables from a database using tables = Utility.DBConnection.GetSchema(Tables, restrictions); How do
I wish fetch data in a XML file, where Tag is a variable.. My

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.