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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T03:26:37+00:00 2026-06-03T03:26:37+00:00

I have a HTML file and when I view it in notepad, I can

  • 0

I have a HTML file and when I view it in notepad, I can see the following:

<p><span>Copyright © 2008 Your Company Name</span>

Notice the copyright symbol:

I load the HTML and perform this on it:

$html = file_get_contents('test.html');
$html = mb_convert_encoding($html, 'HTML-ENTITIES', "UTF-8");
file_put_contents('output.html', $html);

When I view the html again in notepad, the copyright symbol has disappeared and is replaced by a space?!

I want the copyright symbol to be replaced by a &copy; or &#169. Is this not what mb_convert_encoding with the HTML-ENTITIES option does?

This is the test HTML file I am using.

  • 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-03T03:26:38+00:00Added an answer on June 3, 2026 at 3:26 am

    Your test HTML page is not encoded in UTF-8; therefore, when mb_convert_encoding sees the copyright character (ordinal value 169) it doesn’t know what to do with what it perceives as an invalid UTF-8 sequence.

    You should therefore specify the correct input encoding when calling mb_convert_encoding:

    $html = mb_convert_encoding($html, 'HTML-ENTITIES', 'ISO-8859-1');
    

    Alternatively, you can use something like

    $html = htmlentities($html, ENT_COMPAT | ENT_HTML401, 'ISO-8859-1');
    

    Note: I am answering your question directly, but you don’t say what you need the conversion for. It’s possible that there may be a better way to achieve your goal.

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

Sidebar

Related Questions

I have a file called 34.php?session=2534464a39a2c97cb7113689726a4e52 in my /var/www/html folder but I can't view
I have the following code in a partial view file _status.html.erb . <%= if
I have an html file that uses the span keyword in two different ways.
I have a HTML file that has code similar to the following. <table> <tr>
I have a HTML file upload field from which I'm reading the file name
I have a program that creates a html file as standard output. To view
I have msg file which have html mark up if I view it using
Suppose I have changed html file. What is the best way to view results?
I have html file which shows panoramic view of a place. HTML file calls
I have html-file. I have to replace all text between this: [%anytext%]. As I

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.