`
xumingyong
  • 浏览: 175788 次
  • 性别: Icon_minigender_1
  • 来自: 成都
社区版块
存档分类
最新评论

erlang:split_binary(Bin, N)的BUG

阅读更多

OS运行平台:

 

root@x61-laptop:~# cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=8.10
DISTRIB_CODENAME=intrepid
DISTRIB_DESCRIPTION="Ubuntu 8.10"



 

 

ERLANG版本:

 

root@x61-laptop:~# cat /usr/lib/erlang/releases/RELEASES
[{release,"OTP  APN 181 01","R12B","5.6.3",
          [{kernel,"2.12.3","/usr/lib/erlang/lib/kernel-2.12.3"},
           {stdlib,"1.15.3","/usr/lib/erlang/lib/stdlib-1.15.3"},
           {sasl,"2.1.5.3","/usr/lib/erlang/lib/sasl-2.1.5.3"}],
          permanent}].


 

 

操作过程:


Eshell V5.6.3  (abort with ^G)
1> CaptureFile = <<212,195,178,161,2,0,4,0,0,0,0,0,0,0,0,0,96>>.
<<212,195,178,161,2,0,4,0,0,0,0,0,0,0,0,0,96>>

2> A = split_binary(CaptureFile, 1).
{<<"\324"
>>,<<195,178,161,2,0,4,0,0,0,0,0,0,0,0,0,96>>}

3> B = split_binary(CaptureFile, 3).
{<<"\324\303\262"
>>,<<161,2,0,4,0,0,0,0,0,0,0,0,0,96>>}

4> C = split_binary(CaptureFile, 4). 
{<<"\324\303\262\241"
>>,<<2,0,4,0,0,0,0,0,0,0,0,0,96>>}

5> D = split_binary(CaptureFile, 5).
{<<212,195,178,161,2>>,<<0,4,0,0,0,0,0,0,0,0,0,96>>}

6> E = split_binary(CaptureFile, 6).
{<<212,195,178,161,2,0>>,<<4,0,0,0,0,0,0,0,0,0,96>>}

7> 




 

 

这说明split_binary(Bin, N)函数的N如果小于5,则会出错误。

如果Bin超过128M也会出错。

 

 

还有<<"\324\303\262\241">> 是怎么产生的?

 

 

1
0
分享到:
评论
2 楼 mryufeng 2009-04-27  
<<"\324\303\262\241">>  \324是8进制的表示 3* 64+ 2 *8 +4 = 192+16 +4 =212
没什么不对呀。
1 楼 mryufeng 2009-04-26  
你在上面列出的代码还 <<...>>呢,  而且也不说什么平台 什么版本的erlang, 这个问题属于无效的。

相关推荐

Global site tag (gtag.js) - Google Analytics