Ok. It's me, the last time :-)
> Let say I have a small 4byte file with content "AB#0C"
> (ascii: #65,#66,#0,#67)
> I load it (using binary save fread into $txt)
> When I try to get third character (#0), quess what I get:
> $x = ord(substr($txt,2,1))
> $x IS NOT 0!
> $x IS 92, which mean backslash. Fourth char is 48, which
> means "0" and the fifth #67.
> So, PHP replaces any #0 with "\0" in every string internally.
OK. THIS is true just for string obtained by fread()
Strings created internally are OK.
So the solution is:
1) get the string from the file using $str=fread($file,filesize($filename));
2) I realize that in string obtained by fread() the following characters are changed:
#0 () -> #92#48 (\0)
#34 (") -> #92#34 (\")
#39 (') -> #92#39 (\')
#92 (\) -> #92#92 (\\)
3) So solution is before put text into base64_encode procedure, do the following:
4) Now you can encode it.
Futhermore, I was trying to store some string to file using fwrite() method.
fwrite() works fine for all characters except backslash, where you have to
send there double backslash.
So fwrite($file,chr(0)) writes really #0,
but for writing #92 you have to call fwrite($file,chr(92).chr(92));
For writing #0 you can also call fwrite($file,chr(92).chr(48));
( and similary for all four cases stated above in point 3) )
So, a thing, that's all for now
Have a nice day...
This electronic message transmission contains information from TMP Worldwide and is confidential or privileged. The information is intended to be for the use of the individual or entity named above. If you are not the intended recipient, be aware that any disclosure, copying, distribution, or use of the contents of this information is prohibited. If you have received this electronic transmission in error, please notify us by telephone immediately at +44 (0)20 7406 3333
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php