阿拉伯语PDF表单到PHP到MYSQL,Unicode解码?
我使用Acrobat专业人员创建一个PDF表单,表单填充阿拉伯语,我创建了一个PHP文件,以获取表单字段并将其插入到mysql数据库,我尝试用utf_encode解码阿拉伯语文本ãÍã( )和utf_decode()这个词是محمد,数据库是utf8_bin。和解决方案?
I am using Acrobat professional to create a PDF Form, the form is filled with arabic, and I created a PHP file to get the form fields and insert it into a mysql database, I tried decoding the arabic text ãÍãÏ with utf_encode() and utf_decode() the word is محمد and the database is utf8_bin. and solutions?
<?php
error_reporting(E_ALL & ~E_NOTICE);
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "dbTest";
if (isset($_POST['txtName'])) {$txtName= $_POST['txtName'];};
$link = mysqli_connect($servername, $username, $password, $dbname) or die("UNable to connect");
$qq1 = "set character_set_server='utf8'";
$qq2 = "set names 'utf8'";
//mysqli_query($link, $qq1) or die(mysqli_error($link));
//mysqli_query($link, $qq2) or die(mysqli_error($link));
//$txtName = iconv("UTF-8//TRANSLIT//IGNORE", "Windows-1252//TRANSLIT//IGNORE", $txtName);
//$txtName = iconv("Windows-1256//TRANSLIT//IGNORE", "UTF-8//TRANSLIT//IGNORE", $txtName);
$query = "INSERT INTO tblTest Values('$txtName')";
mysqli_query($link, $query) or die(mysqli_error($link));
?>
,这里是数据库
?> and here is the database
CREATE TABLE IF NOT EXISTS `tbltest` (`txtName` varchar(244) COLLATE tf8_bin DEFAULT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
INSERT INTO `tbltest` (`txtName`) VALUES
('ãÍãÏ Úæäí ãÍãæÏ');
仍然不清楚如何提交数据, answer在上述模拟问题中提供。
It's still not clear how you submit the data but the answer is available in the mentioned simliar question.
在PDF 2.0之前,标准提交操作的字符集不能由PDF规范指定/调整,并且读者应用程序可以选择任何适当的字符集。
The charset for a standard submit action is not specified/adjustable by the PDF specification until PDF 2.0 and the reader application may choose any appropriate charset.
使用JavaScript操作以特定字符集而不是提交操作提交表单数据:
Use a JavaScript action to submit the form data with a specific charset instead of a submit action:
submitForm({
cURL: "https://www.example.com/your-script.php",
cSubmitAs: "HTML",
cCharset: 'utf-8'
});