1
ビット構文を使用して任意のサイズの文字列をバイナリに追加する適切な方法はありますか?すべてがリトルエンディアンである必要があります。私はこの試みた:Erlang:ビット構文を使用してリトルエンディアン形式の文字列を追加する
example() ->
Cmd = 16#4e584e43,
Text = "hello::",
<<Cmd:32/unsigned-little-integer,Text/little-bitstring>>.
をしかし、例外を取得:これは何をしたい
** exception error: bad argument
in function bit_size/1
called as bit_size("hello::")
in call from packet:example/0
in call from packet:main/0
はいそうです。私は実際にこれを使うことで実際に動作させました:Header = << Cmd:32/unsigned-little-integer >>、list_to_binary([Header、Text])。ありがとう! – dbryson