'How to use ODBC Driver 17 for SQL Server in PHP to read Arabic letters?

I have already SQL server 2019 running on Windows server 2019 with database contains Arabic letters, I am working on a project of PHP will runs on Linux, so I have to use Microsoft ODBC Driver 17 for SQL Server for compatibility between Windows and Linux, when trying to get data from database which contains Arabic letters I get many question marks instead of Arabic characters.

?????? ???????

This statement should looks like this:

المركز الرئيسى  

my connection string:

        try {
        $connectionInfo = "driver={ODBC Driver 17 for SQL Server}; Server=myServer; Database=myDB}";
        $conn = odbc_connect($connectionInfo, $this->username, $this->password);
        if (!$conn) {
            die($this->FormatErrors("openConnection", odbc_errormsg($conn)));
        }
        echo "Database connected.";
        $this->connection = $conn;
    } catch (Exception $e) {
        $this->writeLog("openConnection", $e->getMessage());
    }

Do I miss any thing to be done to get Arabic letters appears correctly?

Update: Tried to set Windows system local to be Arabic with no luck, however the page will be viewed on many devices with many OS not just Windows.

Query function

    public function executeQueryCommand()
{
    $outputs = odbc_exec($this->connection, "Select branch_name from tblBranches where brid=1");
    if (!$outputs) {
        $error = odbc_errormsg($this->connection);
        throw new Exception('Executing prepared query failed ' . $error);
    } else {
        $rows = array();
        while ($myRow = odbc_fetch_array($outputs)) {
            $rows[] = $myRow; //pushing into $rows array
        }
        odbc_free_result($outputs);
        $this->closeConnection();
        return $rows;
    }
}

Update 2# (On Windows) I tried to make 'User Data Source' in 'ODBC Data Source Administrator (64-bit)' and use this data source in Microsoft Excel to test if Arabic letters appears in question marks or appears as it should be and finally found that Arabic letters appears correctly which means that issue comes from PHP interpreting and not caused by ODBC driver itself. enter image description here

enter image description here



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source