At 22.10.01 21:36, you wrote: > > > Hi folks, > > following problem appeared on PHP 3.0.16 on LINUX > > I have a binary file, where I want to replace some letters > > I do the following: > > $filename = "xyz.sdc"; > > $fd = fopen( $filename, "r+b" ); // also tried "r" > > $x=filesize( $filename ); // this shows the correct filesize 22528 byte > > $contents = fread( $fd, $x ); > > fclose( $fd ); > > $y=strlen($contents); // The first mistake $y = 32956 byte > > echo "BEFORE<br>".$contents; > > $contents=str_replace("UUUUUU","123456", $contents); > > echo "AFTER<br>".$contents; > > > > It seems, that php converts HEX 00 00 to HEX 5C 30 just when it reads the > > data in > > memory because at the BEFORE echo the data will be shown as \0 (hex 00 > 00 ). > > The filesize will be correct when I save the str_replaced text and the > text > > will be cahnged > > correct. > > Any idea, where this comes from?? >Let's start with the fopen(), where the mode expression might be causing >problems - should it be "rb"? >http://www.php.net/manual/en/function.fopen.php > >If the 'binary' component hasn't been recognised it might explain the >"first mistake". >The ensuing problems may even stem from there...
Thanks DLNeil, I tried "rb" "r" "r+b"(C-style) always the same :( Any other suggestions ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]