Php get a certain number of bytes
I want to make a program that will take a certain number of bytes from a file. I have a few questions. 1: How many bytes is a letter? 2: Are all characters (a,b,"space", $,7, &, etc…) the same amount of bytes? 3: How can I make a web page get a certain number of bytes from a file? 4: How can I make sure I don't cut off a word or something?
BTW how do you filter characters like ' " or &?
Thakns in advance!;)
Sorry for triple post!
every charachter is 1 byte.
also in php you can open the file and then you can specify how many bytes of teh file you wish to extract, so you can easily do that.
and there woudlnt be a easy way of making it not cut off a word, because it will read the file based on bytes instead of words. so to make it not cut off 1/2 a word etc you'll have to add a new function that checks the last byte equals a space (the if not add one byte etc), then yuo can be sure it wont cut off a word. ofcourse this will only work on text based files and wont work with exe's / jpgs etc.
The PHP function filesize() will return the number of bytes in the file you provide. So if you're going to read from a file and don't want t count how many bytes are in it, you can do it like this fread($fp, filesize($file));. That way you're pulling out the exact amount of bytes, no need for guess work.