Jump to content

PHP DOM and character set problem


kukipei

Recommended Posts

Hi to all,

 

I am trying to solve one problem couple of days.

I am scraping one html page. Coding of that page is utf-8. There are some east europian characters on that page čćžš etc..

 

This is a code I am using

function handle_final_scrape($html, $ISIN, $mb)
{
    global $database;
    $ind1 = strpos($html, $ISIN);
    $ind1table = strpos($html, "<table", $ind1);
    $ind2table = strpos($html, "</table", $ind1table);
    $table = substr($html, $ind1table, $ind2table + 8 - $ind1table);
    
    echo $table;
    
    $dom = new DOMDocument("1.0", "UTF-8");
    @$dom->loadHTML($table);

 

After echo $table I have table nice printed on screen. I can see letters (ščćđ) nice.

But after dom functions anything I echo on screen instead of čćžđ I get some unknow characters. It is look like that dom functions somehow change encoding.

 

Is it possible to solve this problem.

Best Regards,

Predrag

Link to comment
https://forums.phpfreaks.com/topic/80454-php-dom-and-character-set-problem/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.