Jump to content

Archived

This topic is now archived and is closed to further replies.

flyhoney

Extracting information from a file with fscanf()

Recommended Posts

I run an open source music website where users upload project files from different music creation applications. I have been trying to write a script that will extract useful information from the project files, like application used, version number, plugins etc.. The infomation I need from the file is delimited by Ä and Á. I have been trying to use fscanf to grab the strings with the information I need out of the file, but I cannot seem to get it to work. My code is something like this:

[code]
$filename = "some/file.dat";
$file = fopen ($filename, "r");
while ($file_info = fscanf($file, "Ä%sÁ")) {
   list ($version) = $file_info;
   echo "$version<br>";
}
fclose($file);
[/code]

However this is not really working. Any help would be greatly appreciated.

*I should add that I am viewing the files in a hex editor and that is how I know how the information I want is delimited.

Share this post


Link to post
Share on other sites
try this ok.

example

[code]
$filename = "some/file.dat";
$file = fopen ($filename, "r");
while ($file_info = fscanf($file, "%Ä\s%Á\n")) {
   list ($version) = $file_info;
   echo "$version<br>";
}
fclose($file);
[/code]

Share this post


Link to post
Share on other sites

Thanks for the suggestion. I tried it out, and this is the warning I get:

Warning: fscanf() [function.fscanf]: Bad scan conversion character "Ä"

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.