It's been a long couple of days and my heads getting a little fried. I haven't done very much binary mathematics since leaving university and I'm struggling to work this one out.
I've got a fairly locked down system based on PHP 5.6 that doesn't include the mbstring
functions nor iconv
. I've already got a function (from elsewhere) that converts from UTF-16 to UTF-8, but now I need the reverse.
The algorithm for an individual character seems fairly straightforward when I look at wikipedia, although I'm a little rusty on the exact procedure. I believe that bit-shifting will be necessary etc.
However, I want to do the conversion to an entire string. How can I determine when each character starts and ends?
Can some kind soul out there help me out? I imagine the function itself won't be that complicated to someone who knows what they're doing. I'm so out of practice that I'm getting myself tied up in knots.