PHP is, once again, TRWTF
-
So, I'm currently writing a parser for Exif data because the two PHP libraries I know about are GPL and I can't do that for a non-GPL piece of software (because, you know, selling it) and I can't actually rely on the exif library being present.
So here I am reading bytes out of the file and needing to convert them to numbers to calculate offsets and crap like that. So far so good. So I have a string containing, say,
\x26\x58
which is an offset to later in the file. So far, also so good since this is correct.Now to convert it to a number. And then we see the consistency of PHP approaching Discourse levels.
On the one hand, we have
bindec
which converts a string containing a binary representation of a number into a number. E.g.01000001
to become 65.On the other hand, we have
bin2hex
which converts a string of character literals into a hex number. For example the aforementioned\x26\x58
would become the hex string2658
. (No leading 0x or anything)So to get from this stream of bytes, I either need to hexdec(bin2hex($bytes)) or faff about implementing something that gets the ordinal value of each byte and bit shifts.
All because bin2dec is not a thing and the idea anyone would be pulling bytes from a file and converting them to meaningful numbers is something Jeff would tell me I was doing it wrong.
(Bonus WTF points, of course, because I buttumed bindec worked like bin2hex and operated on a stream of bytes rather than a stream of characters representing bits)
-
If you're dealing with binary data, use this:
-
Calling unpack on individual bytes/shorts/longs actually gets quite expensive and I can't do it with a single call because the data is so variable in ordering.
Exif sucks.
-
hugs
You can do it!
-
because the two PHP libraries I know about are GPL and I can't do that for a non-GPL piece of software (because, you know, selling it)
Fuck GPL
-
-
If you did that, you'd have to license the spiky purple dildo under the GPL.
-
I'm pretty sure if i was creative enough i could find a GPL licensable giant spiky purple dildo
-
Fuck GPL
Yes but I prefer not to have to deal with licensing entanglements for software I'm selling, having observed this before.
Interestingly enough, my very first post on meta.d was about Discourse being GPL...
-
I'm pretty sure if i was creative enough i could find a GPL licensable giant spiky purple dildo
BSD (Big Spiky Dildo) licence is copyleft enough that it's generally not too much of a problem to work with GPL.
-
I had to work with a PHP script yesterday.
It took me about 30 seconds to find something that made me hate PHP.
-
I had to work with a PHP script yesterday.
It took me about 30 seconds to find something that made me hate PHP.
That long? Shiiiiiiiiiiiiiit.
-
The first 20 seconds were spent on a cream ale.
-
make a webservice endpoint of some kind that wraps the GPL libraries, then consume that service in your proprietary code.
-
good, now we just have to find a giant purple version and introduce it, biblically, to a certain someone.
-
make a webservice endpoint of some kind that wraps the GPL libraries, then consume that service in your proprietary code.
You know what's really funny, that would actually be quite legitimate to do. WTF-prone, but legal.
-
good, now we just have to find a giant purple version and introduce it, biblically, to a certain someone.
Is the said someone a neckbeard with some serious interpersonal problems?
-
Good thing the AGPL doesn't get used by anyone, ever!
-
Good thing the AGPL doesn't get used by anyone, ever!
That's because it's stupid. I have actually encountered one project that used it just after AGPL started to be a thing but even they rescinded and changed it to GPL in the end.
-
Is the said someone a neckbeard with some serious interpersonal problems?
Not sure about the neckbeard, but the other part is right!
-
-
oh, well yes. But he's fore version 1. i was thinking of doing beta test on @CodingHorrorBot
-
@accalia Is Doing It Wrong™<t3516p22>
-
-
The PDA thread is that way.
-
that's my line!
-
who said anything about A?
i think that's more PDL (public display of loathing)
-
Good thing the AGPL doesn't get used by anyone, ever!
Scary thing is... they intended GPLv3 to include the AGPL provisions when writing it. Probably until someone pointed out that no one would use GPLv3 if they did that.
-
Scary thing is... they intended GPLv3 to include the AGPL provisions when writing it. Probably until someone pointed out that no one would use GPLv3 if they did that.
Pretty much, yes.
-
i think that's more PDL (public display of loathing)
Listen, some people like that kind of thing. I'm not judging. As far as you know.
-