用Kurdish字体存储数据MySQL?

时间:2022-01-21 00:33:07

Hi so I've made an application in java that lets the user to store data in a MySQL database. Whenever I enter this به‌رواری ده‌رچوون I just get ??????. Is there any way I can fix that? It's really important that this job is done before tomorrow... I've never faced a problem such as this, and now I'm creating a database app for a company in Kurdistan, and now my friend asked, well does it store data with their characters? Heart attack! Please help!

嗨所以我在java中创建了一个应用程序,允许用户将数据存储在MySQL数据库中。每当我输入这个بهرواریدهرچوون我就得到了??????。有什么方法可以解决这个问题吗?明天之前完成这项工作真的很重要......我从来没有遇到像这样的问题,现在我正在为库尔德斯坦的一家公司创建一个数据库应用程序,现在我的朋友问了,它是否存储了数据与他们的人物?心脏病发作!请帮忙!

I'm using PhpMyadmin on a localhost computer using XAMPP

我在使用XAMPP的本地计算机上使用PhpMyadmin

2 个解决方案

#1


What happened:

  • you had utf8-encoded data (good)
  • 你有utf8编码的数据(好)

  • SET NAMES latin1 was in effect (default, but wrong)
  • SET NAMES latin1生效(默认,但错误)

  • the column was declared CHARACTER SET latin1 (default, but wrong)
  • 该列被声明为CHARACTER SET latin1(默认,但错误)

As you INSERTed the data, it was converted to latin1, which does not have values for Arabic (Kurdish/Farsi/etc) characters, so question marks replaced them.

当您插入数据时,它被转换为latin1,它没有阿拉伯语(库尔德语/波斯语/等)字符的值,因此问号替换了它们。

The cure (for future INSERTs):

治愈(对于未来的INSERT):

  • utf8-encoded data (good)
  • utf8编码数据(好)

  • mysqli_set_charset('utf8') (or whatever your client needs for establishing the CHARACTER SET)
  • mysqli_set_charset('utf8')(或客户端建立CHARACTER SET所需的任何内容)

  • check that the column(s) and/or table default are CHARACTER SET utf8
  • 检查列和/或表的默认值是CHARACTER SET utf8

  • If you are displaying on a web page, <meta...utf8> should be near the top.
  • 如果您在网页上显示, 应该在顶部附近。

The discussion above is about CHARACTER SET, the encoding of characters. Now for a tip on COLLATION, which is used for comparing and sorting.

上面的讨论是关于CHARACTER SET,字符的编码。现在获取有关COLLATION的提示,用于比较和排序。

To double check that the data is stored correctly, do SELECT col, HEX(col)....
ه‌رچوون should come back D987E2808CD8B1DA86D988D988D986
Arabic characters in utf8 have hex of D8xx or D9xx.

要仔细检查数据是否正确存储,请执行SELECT col,HEX(col)....هرچوون应该返回D987E2808CD8B1DA86D988D988D986 utf8中的阿拉伯字符具有D8xx或D9xx的十六进制。

(utf8mb4 works just as well as utf8; either works for Arabic.)

(utf8mb4和utf8一样好用;或者适用于阿拉伯语。)

Bad news: The data that was inserted and turned into '???' cannot be recovered.

坏消息:插入的数据变成'???'无法恢复。

#2


put the below code in the connection PHP file then set collation in phpmyadmin (mysql) to utf8_general_ci or utf8_unicode_ci:

将以下代码放在连接PHP文件中,然后在phpmyadmin(mysql)中将collat​​ion设置为utf8_general_ci或utf8_unicode_ci:

<?php
$servername="localhost";
$username="root";
$password="";
$databasename="ab1";
$conn = new mysqli($servername, $username, $password, $databasename);
if ($conn->connect_error) {
die("connection failed" .$conn->connect_error);
}else
echo "connection sucssessfullly";
$conn->query("SET NAMES 'utf8'");
$conn->query("SET CHARACTER SET utf8");
?>

#1


What happened:

  • you had utf8-encoded data (good)
  • 你有utf8编码的数据(好)

  • SET NAMES latin1 was in effect (default, but wrong)
  • SET NAMES latin1生效(默认,但错误)

  • the column was declared CHARACTER SET latin1 (default, but wrong)
  • 该列被声明为CHARACTER SET latin1(默认,但错误)

As you INSERTed the data, it was converted to latin1, which does not have values for Arabic (Kurdish/Farsi/etc) characters, so question marks replaced them.

当您插入数据时,它被转换为latin1,它没有阿拉伯语(库尔德语/波斯语/等)字符的值,因此问号替换了它们。

The cure (for future INSERTs):

治愈(对于未来的INSERT):

  • utf8-encoded data (good)
  • utf8编码数据(好)

  • mysqli_set_charset('utf8') (or whatever your client needs for establishing the CHARACTER SET)
  • mysqli_set_charset('utf8')(或客户端建立CHARACTER SET所需的任何内容)

  • check that the column(s) and/or table default are CHARACTER SET utf8
  • 检查列和/或表的默认值是CHARACTER SET utf8

  • If you are displaying on a web page, <meta...utf8> should be near the top.
  • 如果您在网页上显示, 应该在顶部附近。

The discussion above is about CHARACTER SET, the encoding of characters. Now for a tip on COLLATION, which is used for comparing and sorting.

上面的讨论是关于CHARACTER SET,字符的编码。现在获取有关COLLATION的提示,用于比较和排序。

To double check that the data is stored correctly, do SELECT col, HEX(col)....
ه‌رچوون should come back D987E2808CD8B1DA86D988D988D986
Arabic characters in utf8 have hex of D8xx or D9xx.

要仔细检查数据是否正确存储,请执行SELECT col,HEX(col)....هرچوون应该返回D987E2808CD8B1DA86D988D988D986 utf8中的阿拉伯字符具有D8xx或D9xx的十六进制。

(utf8mb4 works just as well as utf8; either works for Arabic.)

(utf8mb4和utf8一样好用;或者适用于阿拉伯语。)

Bad news: The data that was inserted and turned into '???' cannot be recovered.

坏消息:插入的数据变成'???'无法恢复。

#2


put the below code in the connection PHP file then set collation in phpmyadmin (mysql) to utf8_general_ci or utf8_unicode_ci:

将以下代码放在连接PHP文件中,然后在phpmyadmin(mysql)中将collat​​ion设置为utf8_general_ci或utf8_unicode_ci:

<?php
$servername="localhost";
$username="root";
$password="";
$databasename="ab1";
$conn = new mysqli($servername, $username, $password, $databasename);
if ($conn->connect_error) {
die("connection failed" .$conn->connect_error);
}else
echo "connection sucssessfullly";
$conn->query("SET NAMES 'utf8'");
$conn->query("SET CHARACTER SET utf8");
?>