MySQL - 俄语字符显示不正确

发布于 2024-10-05 01:35:10 字数 436 浏览 2 评论 0原文

我必须制作一个网站的俄语版本,但我不知道如何将俄语字符插入数据库。

我尝试了几乎所有可能的编码,但它只显示:

???????? ?????????? ??????? ??????? ? ????? ?? ????????????? ? ???????, ??????? ????? ??????? ???????? ????? .??? ??????????? ???????? ????? ?? ????? ?????????? ? ????? ????????.
??????????? ?????? ?? ???????? ????? ?? 20 ???????. ???????? ??? ?? ??????????? ?????????????? ????? ? ????????????? ??????? ??????. ? ???????, ? ??????? ? ?.?. 

I have to make an russian version of a website, but I can't find out, how to insert russian characters into Database.

I tryed almost every possible coding, but it only shows:

???????? ?????????? ??????? ??????? ? ????? ?? ????????????? ? ???????, ??????? ????? ??????? ???????? ????? .??? ??????????? ???????? ????? ?? ????? ?????????? ? ????? ????????.
??????????? ?????? ?? ???????? ????? ?? 20 ???????. ???????? ??? ?? ??????????? ?????????????? ????? ? ????????????? ??????? ??????. ? ???????, ? ??????? ? ?.?. 

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

或十年 2024-10-12 01:35:10
  1. 确保数据库字符集/排序规则为 UTF-8
  2. 在插入这些俄语字符(表单、textarea)的页面上,通过将 Content-Type 设置为 text/html 来确保编码为 UTF-8;字符集=utf-8。直接在表单输入中输入俄语文本。
  3. 在处理此表单(将其插入数据库)的处理页面上,请确保执行SET NAMES utf8,以便在插入数据之前将其存储为 UTF-8,事先在单独的查询中。
  4. 当您在视图中呈现数据库中的内容时,请确保 Content-Typetext/html;字符集=utf-8

确保内容类型不是 windows-1251 或 iso-8859-1/latin1。确保数据库字符集/排序规则不是 ISO-8859-1/Latin1。

  1. Make sure the database charset/collation is UTF-8
  2. On the page you insert these russian characters ( the form, textarea ), make sure the encoding is UTF-8, by setting Content-Type to text/html; charset=utf-8. Enter in russian text directly to the form input.
  3. On the processing page that handles this form, which inserts it into the database, make sure to do SET NAMES utf8 so it's stored as UTF-8 before you insert the data, in a separate query beforehand.
  4. When you render the content from the database in a view, make sure the Content-Type is text/html; charset=utf-8.

Make sure that the content-type is not windows-1251 or iso-8859-1/latin1. Make sure the database charset/collation is NOT ISO-8859-1/Latin1.

爱人如己 2024-10-12 01:35:10

为了在数据库中存储俄语字符,您的数据库应该支持 UTF-8 编码。
使用以下查询修改您的表以启用 UTF-8 编码。

ALTER TABLE t1 CONVERT TO CHARACTER SET utf8

For storing russian characters in db your db should support UTF-8 encoding.
Modify your table with below query to enable UTF-8 encoding.

ALTER TABLE t1 CONVERT TO CHARACTER SET utf8
牵强ㄟ 2024-10-12 01:35:10

确保您的数据库表设置为 UTF-8 编码。您可以运行以下 SQL 查询:

ALTER TABLE `table` CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;

确保您的数据库连接也使用 UTF-8 编码:

$conn = new mysqli($servername, $username, $password, $dbname);
$conn->set_charset('utf8');

确保您的 HTML 表单配置为使用 UTF-8 编码:

<head>
<meta charset="UTF-8">
</head>

Make sure that your database table is set to UTF-8 encoding. You can run the following SQL query:

ALTER TABLE `table` CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;

Make sure that your database connection also uses UTF-8 encoding:

$conn = new mysqli($servername, $username, $password, $dbname);
$conn->set_charset('utf8');

Make sure that your HTML form is configured to use UTF-8 encoding:

<head>
<meta charset="UTF-8">
</head>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文