在Erlang中连接BitStrings(不是Binaries) [英] Concatenating BitStrings (Not Binaries) in Erlang

查看:157
本文介绍了在Erlang中连接BitStrings(不是Binaries)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你如何连接bitstrings。我的意思是bitstrings,因为我不知道字节数是8的倍数。

How do you concatenate bitstrings. I mean bitstrings because I do not know the number of bytes to be a multiple of 8.

A = <<3:2>>
B = <<1:1>>
C = <<15:4>>

Solution should A|B|C should be <<127:7>>

谢谢

推荐答案

使用 / bitstring 和所有以前的值构造二进制文件。这是一个例子,运行在erlang shell中:

Construct the binary using /bitstring and all the previous values. Here's an example, running in the erlang shell:

1> A = <<3:2>>.
<<3:2>>
2> B = <<1:1>>.
<<1:1>>
3> C = <<15:4>>.
<<15:4>>
4> D = <<A/bitstring, B/bitstring, C/bitstring>>.
<<127:7>>

这篇关于在Erlang中连接BitStrings(不是Binaries)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆