缓冲区以字符串为字符串字符串

发布于 2025-02-02 12:57:42 字数 189 浏览 2 评论 0原文

在node.js中,我将获得一个缓冲结果,例如:

< buffer 21 61 0b>

如何将其转换为这样的字符串:

“ 21610b”

所有方法我在网上看到的建议是将缓冲区转换为字符串,但这将改变布局。我想保留与字符串完全相同的布局。

In Node.js I am getting a buffer result as:

<Buffer 21 61 0b>

How can I convert this to a string like this:

“21610b”

All the methods and suggestions I have seen online are for converting the buffer to a string but that will change the layout. I want to keep the exact same layout as string.

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

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

发布评论

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

评论(1

浅忆 2025-02-09 12:57:42

控制台通过在十六进制符号中显示前几个字节来概括缓冲对象。要将缓冲区转换为十六进制的字符串,请使用.tostring('hex')

The console summarizes Buffer objects by displaying the first few bytes in hexadecimal notation. To convert a Buffer to a string of hexadecimals, use .toString('hex').

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