Joe
Translating binary to English string?
Moderator: General Moderators
-
joetheeskimo5
- Forum Commoner
- Posts: 43
- Joined: Sun Dec 14, 2003 4:47 pm
- Location: US
- Contact:
Translating binary to English string?
I just started PHP yesterday, and I was wondering if there's a function to translate a binary string to an English string. I know there's one to translate a string to binary, but not the other way around. Please help!
Joe
Joe
-
joetheeskimo5
- Forum Commoner
- Posts: 43
- Joined: Sun Dec 14, 2003 4:47 pm
- Location: US
- Contact:
Binary is a computer language, made up of 1's and 0's. An English string is a string of text in English. For example, the words I'm writing now is an English string. How can you not know that if you're a programmer?! 
Computers can't hold anything but binaries, didn't you knew it?
So the words you wrote is stored in db in sort of binary string... There is plenty of formats, which one you call `English`? 
They all are made up of 1's and 0's.
Do you call `binary` C-like strings, made of ASCII representations of characters ended with zero byte? Or you're talking about Pascal string which holds its length as few first bytes? Or something else you could imagine?
They all are made up of 1's and 0's.
Do you call `binary` C-like strings, made of ASCII representations of characters ended with zero byte? Or you're talking about Pascal string which holds its length as few first bytes? Or something else you could imagine?
-
Paddy
- Forum Contributor
- Posts: 244
- Joined: Wed Jun 11, 2003 8:16 pm
- Location: Hobart, Tas, Aussie
- Contact:
I don't know of a functin that does what you want but if I had your prob I would take eight characters out of the binary string at a time and then use chr to convert it from ascii to a character. You can find more info on chr here
http://au2.php.net/manual/en/function.chr.php
http://au2.php.net/manual/en/function.chr.php
-
microthick
- Forum Regular
- Posts: 543
- Joined: Wed Sep 24, 2003 2:15 pm
- Location: Vancouver, BC
If you were to open a binary file and read in 8 characters, you'd be reading in 64 bits, and by using chr() on each of this 8 characters, you'd output the same character that you just imputted.
I think the poster needs to clarify what he means to do.
The only sensible thing I can interpret his post to mean is this.
Assume you have a text file that contains only 1's and 0's, meaning it contains strings like "01001000" or "01000010". But if this is the case, if you were to look at the binary representation of these strings, each of these strings would be made up of 64 bits of 0's and 1's. Ie, string #1 would be represented by "0011000000110001001100000011000000110001001100000011000000110000".
If this is the case, then yes, what Paddy described would be what you do.
I think the poster needs to clarify what he means to do.
The only sensible thing I can interpret his post to mean is this.
Assume you have a text file that contains only 1's and 0's, meaning it contains strings like "01001000" or "01000010". But if this is the case, if you were to look at the binary representation of these strings, each of these strings would be made up of 64 bits of 0's and 1's. Ie, string #1 would be represented by "0011000000110001001100000011000000110001001100000011000000110000".
If this is the case, then yes, what Paddy described would be what you do.