将希伯来字符插入 MySql DB

发布于 2024-10-18 05:27:01 字数 194 浏览 7 评论 0原文

我有一个连接到 MySql 数据库的 asp.net 页面。

当我尝试将网页中的值插入/更新到数据库时 字符在数据库中显示为问号(我正在使用 SP)。 如果我直接在数据库中编写查询,它将起作用并且字符 将正确显示。

DB默认字符集是utf8,列排序规则是utf8_general_ci。

10x很多&祝周末愉快:)

I have an asp.net page connected to a MySql DB.

When I try to insert/update values from the webpage into the DB
the chars are shown in the DB as question marks (I am using SP).
If i will write a query directly in the DB, It will work and the chars
will be displayed correctly.

The DB default charset is utf8, and the column collation is utf8_general_ci.

10x alot & Have a great weekend :)

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

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

发布评论

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

评论(2

睫毛溺水了 2024-10-25 05:27:01

最终解决我问题的方法是将 CharSet=utf8 添加到连接字符串中。

每个人都 10 倍:)

Eventually what solved my problem is adding CharSet=utf8 to the connection string.

10x alot everyone :)

池予 2024-10-25 05:27:01

我相信您的 C# 字符串被视为 unicode 而不是 UTF8

我前一段时间找到的片段中的一些示例代码:

System.Text.Encoding utf_8 = System.Text.Encoding.UTF8;

// This is our Unicode string:
string s_unicode = "abcéabc";

// Convert a string to utf-8 bytes.
byte[] utf8Bytes = System.Text.Encoding.UTF8.GetBytes(s_unicode);

// Convert utf-8 bytes to a string.
string s_unicode2 = System.Text.Encoding.UTF8.GetString(utf8Bytes);

MessageBox.Show(s_unicode2);

I believe your C# strings are being treated as unicode instead of UTF8

Some sample code from a snippet I had found some time ago:

System.Text.Encoding utf_8 = System.Text.Encoding.UTF8;

// This is our Unicode string:
string s_unicode = "abcéabc";

// Convert a string to utf-8 bytes.
byte[] utf8Bytes = System.Text.Encoding.UTF8.GetBytes(s_unicode);

// Convert utf-8 bytes to a string.
string s_unicode2 = System.Text.Encoding.UTF8.GetString(utf8Bytes);

MessageBox.Show(s_unicode2);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文