Join us at IRC!
Imagination is more valuable than knowledge - Albert Einstein
Friday, May 25, 2012
Navigation
Members Online
Total Online: 34
Web Spiders: 15
Guests Online: 33
Members Online: 1

Registered Members: 70208
Newest Member: andresuran
Latest Articles
View Thread

HellBound Hackers | Computer General | Programming

Author

Php get a certain number of bytes

ranma
Member



Posts: 269
Location: Behind a sphere
Joined: 27.08.05
Rank:
HBH Guru
Posted on 22-05-06 00:30
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!

Edited by ranma on 22-05-06 00:33
Author

RE: Php get a certain number of bytes

Mr_Cheese
HBH Owner



Posts: 2468
Location: Brighton, UK
Joined: 30.11.04
Rank:
God
Posted on 22-05-06 00:37
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.


Author

RE: Php get a certain number of bytes

revolt0163
Member

Posts: 46
Location:
Joined: 23.04.06
Rank:
HBH Guru
Posted on 22-05-06 02:13
usually 1 character = 1 byte

but in the case of unicode

1 unicode character = 2 bytes


Author

RE: Php get a certain number of bytes

Xero
Member

Posts: 259
Location: AmeriKKKa
Joined: 04.12.04
Rank:
Hacker Level 2
Posted on 22-05-06 02:24
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.



http://php.net/filesize
Guest
Username

Password

Remember Me


Bookmark This Page
Affiliates
Adverts

 

 

Links
By using, viewing or obtaining any information contained on this site, you agree to the disclaimer.

© HellBound Hackers 2008- 2009. Since 3rd December 2004.