Base64 编码空终止符

发布于 2025-01-07 15:20:04 字数 358 浏览 2 评论 0原文

您好,我目前正在尝试使用 C++ 中的 base64 编码方法对字符串进行编码。

字符串本身编码得很好,但是我希望在解码字符串的末尾有一个额外的空字符(因此空字符也会显示在我想要将解码字符串保存到的文本文件中)。

我在这里使用这个base64代码-> http://www.adp-gmbh.ch/cpp/common/base64.html

我希望你能给我一些建议,我可以在这里做什么来实现这一点(我已经尝试在我正在编码的字符串末尾写入两个空字符,但似乎编码方法只读取到第一次出现空值 特点)。

Hi I am currently trying to encode a string using the base64 encoding method in C++.

The string itself encodes fine however I would like to have an extra null character at the end of the decoded string (so the null character would also show up in the text file I want to save the decoded string into).

I am using this base64 code here -> http://www.adp-gmbh.ch/cpp/common/base64.html

I hope you can give me some advices what I can do here to make this possible (I tried already writing two null characters at the end of the string I am encoding but it seems as if the encoding method only reads to the first occurence of a null character).

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

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

发布评论

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

评论(1

不离久伴 2025-01-14 15:20:04

粗略地看一下编码函数似乎没有显示出对 NUL 的任何特殊处理。解码功能也不起作用,您确定问题不是在解码字符串中测试 NUL 的方式吗?

A cursory lookat the encoding function does not seem to show any special handling of NUL. And neither does the decoding function, are you sure the issue is not in the way that you test for NUL in the decoded string?

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