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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T09:03:25+00:00 2026-06-11T09:03:25+00:00

I am using PHP Simple HTML DOM Parser http://simplehtmldom.sourceforge.net/ to fetch data like Page

  • 0

I am using PHP Simple HTML DOM Parser http://simplehtmldom.sourceforge.net/ to fetch data like Page Title, Meta Description and Meta Tags from other domains and then insert it into database.

But I have some issues with encoding. The problem is that I do not get correct characters from those website which is not in English Language.

Below is the code:

<?php
require 'init.php';

$curl = new curl();
$html = new simple_html_dom();

$page = $_GET['page'];

$curl_output = $curl->getPage($page);

$html->load($curl_output['content']);
$meta_title = $html->find('title', 0)->innertext;

print $meta_title . "<hr />";

// print $html->plaintext . "<hr />";
?>

Output for facebook.compage

Welcome to Facebook — Log in, sign up or learn more

Output for amazon.cnpage

亚马逊-网上购物商城:è¦ç½‘è´­, å°±æ¥Z.cn!

Output for mail.rupage

Mail.Ru: почта, поиÑк в интернете, новоÑти, игры, развлечениÑ

So, the characters is not being encoded properly.

Can anyone help me how to solve this issue so that I can add correct data into my database.

  • 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-11T09:03:26+00:00Added an answer on June 11, 2026 at 9:03 am

    @deceze and @Shakti thanks for your help.

    +1 for the article link posted by deceze (Handling Unicode Front to Back in a Web App) and it also worth reading Understanding encoding

    After reading your comments, answer and of course those two articles, I finally solved my issue.

    I have listed the steps I did so far to solve this issue:

    1. Added header('Content-Type: text/html; charset=utf-8'); on the top of my init.php file,
    2. Changed CHARACTER SET of my database table field which is storing those value to UTF-8,
    3. Set MySQL connection charset to UTF-8 mysql_set_charset('utf8', $connection_link_id);
    4. Used htmlentities() function to convert characters $meta_title = htmlentities(trim($meta_title_raw), ENT_QUOTES, 'UTF-8');

    Now the issue seems to be solved, BUT I still have to do following thing to solve this issue in FULL.

    1. Get the encoded charset from the source $source_charset.
    2. Change the encoding of the string into UTF-8 if it is already not in the same encoding. For this the only available PHP function is iconv(). Example: iconv($source_charset, "UTF-8", $meta_title_raw);

    For getting $source_charset I probably have to use some tricks or multi checking. Like checking headers and meta tag etc. I found a good answer at Detect encoding

    Let me know if there are any improvements or any fault on my steps above.

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

Sidebar

Related Questions

I'm hoping someone can help me. I'm using PHP Simple HTML DOM Parser (http://simplehtmldom.sourceforge.net/manual.htm)
I'm using PHP simple dom parser http://simplehtmldom.sourceforge.net/manual.htm . I'm able to successfully use it
I was just about to attempt scraping using the Simple HTML DOM Framework: http://simplehtmldom.sourceforge.net/
I am using PHP Simple HTML DOM Parser to fetch urls, but i got
I am using PHP Simple HTML DOM Parser and it is consuming a lot
I am learning scraping using the PHP Simple HTML DOM Parser and Xpath. Accroding
I have the Simple HTML DOM Parser for PHP, and I am using the
I've parsed a HTML document using Simple PHP HTML DOM Parser. In the parsed
I'm using the Simple php DOM Parser to parse an html table and count
Suppose i have fetched a images using PHP Simple HTML DOM Parser and obtain

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.