I have some persian/farsi characters stored in a database for a multilingual website and I am creating a simple extension to export the content of this table into a text file.
The export works fine with normal english characters of the table, but the persian characters are exported in unicode i believe. This is how they are stored on the database:

This is the function that I have to write the table to a file:
public function setData($data)
    {
        $handle = fopen($this->getFilename(), "w");
        fwrite($handle, $data);
        fclose($handle);
        header('Content-Type: application/octet-stream; charset=UTF-8');
        header('Content-Disposition: attachment; filename='.basename($this->getFilename()));
        header('Expires: 0');
        header('Cache-Control: must-revalidate');
        header('Pragma: public');
        header('Content-Length: ' . filesize($this->getFilename()));
        readfile($this->getFilename());
    }
$data is a string, another function converts all the rows and columns and puts them into a string.
How can I convert the data from how it is (in the picture above) into normal readable characters?
I apologize if this is a duplicate but I've tried many solutions online to try to convert this and none of them has worked so far.
