vala-字节转换为字符串?

发布于 2025-02-12 03:51:14 字数 235 浏览 0 评论 0原文

我有一个 glib.bytes 对象。

我想打印它并将其用作字符串这样:

Bytes bytes = new Bytes({65, 66, 67});

print(bytes); // <-- ERROR

如何将其转换为字符串?

I have a GLib.Bytes object.

I want to print it and use it as a string like this:

Bytes bytes = new Bytes({65, 66, 67});

print(bytes); // <-- ERROR

How can I convert it to string?

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

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

发布评论

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

评论(1

七堇年 2025-02-19 03:51:14

获取 RAW BYTE数组 uint8 [] with bytes.get_data() cast 作为字符串。

示例:

Bytes bytes = new Bytes({65, 66, 67});

string str = (string)bytes.get_data();
print(str);

输出:

ABC

Get raw byte array uint8[] with Bytes.get_data() and cast it as string.

Example:

Bytes bytes = new Bytes({65, 66, 67});

string str = (string)bytes.get_data();
print(str);

Output:

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