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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.