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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T06:46:04+00:00 2026-06-12T06:46:04+00:00

I have a problem regarding PHP, CURL and UT-8 Greek characters. I try to

  • 0

I have a problem regarding PHP, CURL and UT-8 Greek characters.

I try to retrieve some text from a website (a blog specifically), but when i read the retrieved text it is corrupted. It shows up something like Î ÏκοÏÏÏ ÏÎ¿Ï ÏÏÏÏον. The english characters on the other hand show up nice.

The website’s charset is ‘UTF-8’ and so is the charset in my script.

I use the following settings for CURL.

$ch = curl_init();
$useragent='Mozilla/5.0 (Windows NT 6.1; rv:15.0) Gecko/20120716 Firefox/15.0a2';
$header = array('Accept-Charset: UTF-8');

curl_setopt($ch, CURLOPT_FAILONERROR, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_AUTOREFERER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_MAXREDIRS, 2);
curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
curl_setopt($ch, CURLOPT_ENCODING, "");
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_TIMEOUT, 3);    

I use an Xpath Query $res=$xp->query("...") to find the place of the text.

Then i take the text like this:

foreach($res as $text_result)
    $texter=trim($text_result->nodeValue);

I checked the returned text charset with mb_detect_encoding and its properly ‘UTF-8’.

The script runs correctly with most of the websites, but it fails with two of them.
I can’t figure out what the problem may be.

Does anyone have an idea?
Thank you all in advance.

UPDATE

I have fixed the error by adding this:

$doc->loadHTML('<?xml encoding="UTF-8">' . $html);

but now, when i insert the text into the database, they remain corrupted. The same in my pc (easyphp) works fine.

I own a free host at 000webhost.

  • 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-12T06:46:05+00:00Added an answer on June 12, 2026 at 6:46 am

    I found the solution.

    I had to convert the html entities encoding, by:

    @$dom->loadHTML(mb_convert_encoding($data, 'HTML-ENTITIES', 'UTF-8'));
    

    Solution was given here: solution

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

Sidebar

Related Questions

I have a problem regarding this two values from my textboxes (text, text2), seems
I have a problem regarding display PHP code (stored in a database) on a
I have one problem regarding the data insertion in PHP. In my site there
i have a problem regarding the responseXML of ajax.. I have this code from
i have a small problem regarding jquery/php. in the last few days i built
I have one problem regarding retriving data from database. I have created one database
I have a specific problem regarding my website that I built with HTML, CSS,
I have a problem regarding StartUp Url in WPF. I have a LoginView.xaml and
I have a problem regarding the datediff MYSQL function, I can use it and
I have a problem regarding the ksoap2. My problem is that the project used

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.