I have a web application I wrote using ASP.NET couple years ago, it saves form data into mdb database and then convert it to XLS file when the user chooses to.
I changed the form handling code into php and I noticed that arabic characters are converted to a different charset.
Example: تجربة
will be stored as تجربة
I can convert it back to arabic when pasting it in the UTF8-Encoded field using this online tool.
here is the code:
ini_set('default_charset', 'utf-8');
header('Content-Type: text/html;charset=utf-8');
$dbName = "DB\DB.mdb";
if (!file_exists($dbName)) {
die("Could not find database file.");
}
$connection = odbc_connect("Driver={Microsoft Access Driver (*.mdb)};Dbq=$dbName", "", "");
odbc_exec($connection , "SET NAMES 'UTF8'");
odbc_exec($connection , "SET client_encoding='UTF-8'");
$stmt="INSERT INTO arabic_table (val) VALUES('".$_POST["arabicTxT"]."')";
$resultset=odbc_exec($connection,$stmt);
Please note: I converted all files to utf-8 using notepad. I tested the arabic inputs by 'echo'ing them back before storing them, and they are in the correct charset. ASP does store arabic characters perfectly. I do not have any PDO drivers in my shared hosting.
I have searched a solution for hours with no luck, any ideas?
Thanks in advance.