从DAT文件中获取信息

时间:2015-08-18 14:34:29

标签: php multithreading binary

我想知道在php中是否有办法读取dat文件中包含的信息? 如果使用编辑器打开文件,则文件内容如下:

0000 0000 0002 0091 0000 0091 0000 744f
7053 0000 0000 00e0 8100 0000 0000 0000
0000 0000 0000 0000 0000 0000 0200 0000
0b00 0000 1000 0000 4d00 0000 6b00 0000
7f00 0000 8f00 0000 8f00 0000 8f00 0000
8f00 0000 8f00 0000 8f00 0000 8f00 0000
8f00 0000 8f00 0000 8f00 0000 8f00 0000
8f00 0000 8f00 0000 8f00 0000 8f00 0000
8f00 0000 8f00 0000 8f00 0000 8f00 0000
8f00 0000 8f00 0000 8f00 0000 8f00 0000
8f00 0000 8f00 0000 8f00 0000 8f00 0000
8f00 0000 8f00 0000 8f00 0000 8f00 0000
8f00 0000 8f00 0000 8f00 0000 8f00 0000
8f00 0000 8f00 0000 8f00 0000 8f00 0000
8f00 0000 8f00 0000 8f00 0000 8f00 0000
8f00 0000 8f00 0000 8f00 0000 8f00 0000
8f00 0000 8f00 0000 8f00 0000 8f00 0000
0000 0000 0000 0000 0200 0000 0b00 0000

等等...事情是我已经阅读了一些行并看到了一些信息,但它充满了奇怪的符号......是否有方法或特殊配置可供阅读?。

我使用的代码是:

<?php
   //Storing the previous encoding in case you have some other piece 
   //of code sensitive to encoding and counting on the default value.      
   $previous_encoding = mb_internal_encoding();

   //Set the encoding to UTF-8, so when reading files it ignores the BOM       
   mb_internal_encoding('UTF-8');

   //Process the CSS files...

   //Finally, return to the previous encoding
   mb_internal_encoding($previous_encoding);

   //Rest of the code...
// Provee.Dat
$data = fopen('Provee.Dat', "rb");
while(!feof($data)) {
  echo preg_replace('/[\x00-\x1F\x80-\xFF]/', '', fgets($data)) . "<br>";
}
fclose($data);
?>

0 个答案:

没有答案