问题描述
我正在一个项目中,他们在mysql数据库的BLOB type列中存储了以下类型的编码数据。我四处询问,并被告知这是Bencode,但是,据我在线所见,它似乎不是标准的Bencode。
I'm working on a project in which they have stored the following type of encoded data in a BLOB type column of a mysql database. I've asked around and have been told this is Bencode, however, from what I'm seeing online it doesn't appear to be standard Bencode.
Wiki for Bencode
编码数据示例
a:11:{i:0;a:3:{s:11:"question_id";s:2:"46";s:6:"answer";s:1:"2";s:7:"correct";b:1;}i:1;a:3:{s:11:"question_id";s:2:"45";s:6:"answer";s:1:"2";s:7:"correct";b:0;}i:2;a:3:{s:11:"question_id";s:2:"44";s:6:"answer";s:1:"2";s:7:"correct";b:0;}i:3;a:3:{s:11:"question_id";s:2:"43";s:6:"answer";s:1:"1";s:7:"correct";b:0;}i:4;a:3:{s:11:"question_id";s:2:"42";s:6:"answer";s:1:"3";s:7:"correct";b:0;}i:5;a:3:{s:11:"question_id";s:2:"41";s:6:"answer";s:1:"2";s:7:"correct";b:0;}i:6;a:3:{s:11:"question_id";s:2:"40";s:6:"answer";s:1:"0";s:7:"correct";b:1;}i:7;a:3:{s:11:"question_id";s:2:"39";s:6:"answer";s:1:"0";s:7:"correct";b:0;}i:8;a:3:{s:11:"question_id";s:2:"38";s:6:"answer";s:1:"1";s:7:"correct";b:1;}i:9;a:3:{s:11:"question_id";s:2:"37";s:6:"answer";s:1:"3";s:7:"correct";b:0;}i:10;a:3:{s:11:"question_id";s:2:"36";s:6:"answer";s:1:"2";s:7:"correct";b:1;}}
到目前为止我所注意到的
我注意到编码描述了不同的内容
I've noticed that the encoding describes different types of data using letters and integers similar to Bencode.
示例:
s:11: question_id;
我假设 s
代表字符串,而 11
定义字符串 question_id
的长度。同样,数据的开头( a:11:
)似乎描述了一个长度为11的数组。尽管这与标准Bencode相似,但它并没有似乎没有使用Bencode所使用的标准语法。
I'm assuming s
stands for 'string', and that 11
is defining the length of the string question_id
. Also, it would appear that the beginning of the data (a:11:
) describes an array with a length of 11. While this is similar to standard Bencode, it doesn't seem to use the standard syntax that Bencode uses.
是否有人知道这是什么类型的编码?这是非标准的Bencode格式,还是完全不同?我正在寻找PHP或Python中的解析器,并且为编码指定名称肯定会对我的搜索有所帮助。
Does anyone have any ideas what type of encoding this is? Is this a non-standard Bencode format, or something entirely different? I'm looking for a parser in PHP or Python, and having a name for the encoding would definitely help in my search.
推荐答案
这是PHP序列化格式,可使用进行序列化。 br>
请参见。
It's the PHP serialization format, unserializable using unserialize
.
See http://codepad.org/l7Z9cITo.
这篇关于这是什么类型的编码?有人告诉我它是Bencode,但它看起来并不标准的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!