Проблема турецкой кодировки URLEncoder
Java-коды;
URL url = new URL(register_url);
HttpURLConnection httpURLConnection = (HttpURLConnection)url.openConnection();
httpURLConnection.setRequestMethod("POST");
//httpURLConnection.setRequestProperty("Accept-Charset", "UTF-8");
//httpURLConnection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded;charset=" + "UTF8");
httpURLConnection.setDoOutput(true);
httpURLConnection.setDoInput(true);
OutputStream outputStream = httpURLConnection.getOutputStream();
BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(outputStream, "UTF-8"));
String post_data = URLEncoder.encode("user_name", "UTF-8")+"="+URLEncoder.encode(user_name, "UTF-8")+"&"+URLEncoder.encode("password", "UTF-8")+"="+URLEncoder.encode(password, "UTF-8");
//String post_data = "user_name="+user_name+"&password="+password;
Log.d("Kayıt Ol Argümanları", post_data);
bufferedWriter.write(post_data);
bufferedWriter.flush();
bufferedWriter.close();
outputStream.close();
InputStream inputStream = httpURLConnection.getInputStream();
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream, "ISO-8859-1"));
String result="";
String line="";
while ((line = bufferedReader.readLine()) != null){
result+=line;
}
bufferedReader.close();
inputStream.close();
httpURLConnection.disconnect();
Коды PHP;
<?php
require "ayar.php";
$user_name = $_POST["user_name"];
$user_pass = $_POST["password"];
//$user_name = mb_convert_encoding($user_name, "UTF-8");
//$user_pass = mb_convert_encoding($user_pass, "UTF-8");
//$user_name = "üğşçöı";
//$user_pass = "asd";
if (is_null($user_name) & is_null($user_pass)) {
echo "Boş Kısımlar Var";
}else{
$mysql_qry = "insert into android (ad, sifre) values ('$user_name', '$user_pass')";
if ($conn -> query($mysql_qry) === TRUE) {
echo "Insert Success ";
}else{
echo "Error: " . $mysql_qry . "<br>" . $conn->error;
}
$conn->close();
}
?>
Ввод Android;
üğşçöı
Печать журнала Android
user_name =% C3% до н.э.% C4% 9F% C5% 9F% C3% А7% C3% B6% C4% B1
Вывод MySQL; (utf8_general_ci и latin5_turkish_ci)
üÄ? Å? Ã§Ã¶Ä ±
Это моя проблема.
Я только что решил использовать PDO в моих кодах PHP.