在 Qt 中的 QPlainText 小部件中可视化原始文本时出现问题

发布于 2024-11-24 12:09:05 字数 228 浏览 2 评论 0原文

我正在尝试制作一个 Base64 编码器/解码器并在 Ubuntu 中的 Qt (4.7.3) 中可视化结果。

我使用 QPlainText 来粘贴代码并呈现结果。我解码没有问题,因为结果是正确的,但是当我尝试加密时,结果是汉字和不可读的字符。

我认为我的错误与小部件的编码或 QString 有关,因为编码算法是正确的。

一些想法? 谢谢!

I'm trying to make a base64 coder/decoder and visualize results in Qt (4.7.3) in Ubuntu.

I'm using both QPlainText to paste code and to present results. I have no problem decoding, because the result is correct, but when I try to encrypt, the results are Chinese character and non readable chars.

I think that my error is with the encoding of the widget or with the QString, because the codification algorithm is correct.

Some ideas?
Thanks!

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

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

发布评论

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

评论(1

孤独患者 2024-12-01 12:09:05

如果编码以 8 位工作,它可能会偶然产生代表中文字符(或来自其他语言)的 UTF-8 字符序列。这还取决于您选择的默认 QString 编码等,但使用 base64 时,它将适用于任何编码。对于编码字符串,请尝试在将其显示到小部件之前对其进行 base64 处理。

If encoding works in 8 bit, it may produce, by chance, UTF-8 sequences of characters that represent chinese characters (or from other languages, for the matter). This also depends on the default QString encoding you selected, etc., but with base64 it will work for any encoding. For the encoded string, try to base64 it before showing it into the widget.

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