I'm trying to match file names associated with a 3DS file (a 3DS file is a
common 3D file format).  The file is binary by nature but as you can clearly
see in the dump below the filenames themselves are stored as plain text.
So I should be able to do a simple eregi() on the file and discover if the
filename exists within that file or not, right?

<? // here's just some simple test code...
 $imagename = "PYRSTN01.JPG";

 $path = "/home/placest/exchange/test.3ds";
 $fp = fopen($path, "r");
 if ($fp !== false)
 {
  $file = fread($fp, filesize($path));
  fclose($fp);

  $result = eregi($imagename, $file);
  if ($result == true)
  {
   echo "FOUND IT";
  }
  else
  {
   echo "COULD NOT FIND IT";
  }
 }
?>

Here's a snipplet of the file dump to the screen.  You can quite plainly see
that "PYRSTN01.JPG" exists as text in this string.  Now if I copy a portion
of this string and paste it into my code of course it works and echos 'found
it'.  But if I perform the eregi() function on the raw string read directly
from the file it prints 'could not find it'... why?  Isn't it the same exact
thing?
-------------------------------------------------------------------
.....0¡„ 0 Š ‡  €?¢30d£PYRSTN01.JPGQ£S£ 
€?@vBox01AjAhƒ:oƒ:oƒ.....
-----------------------------------------------------------------------

To be honest I don't know or even care about the difference between ASCII
and BINARY.  In this case all I want to do is locate the plain text,
"PYRSTN01.JPG" within the 3DS file string.  But clearly I'm missing some
vital bit of information or there's something I don't understand about binay
strings being interpreted as ASCII?  Anyone know how I can make this work?

Much thanks,
-Kevin


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to