Jump to content


This topic is now archived and is closed to further replies.


accesing string bytes

Recommended Posts


I want to write some character encoding conversion function, and I ran into
a problem: when I try to white characters in a string, I'm only able to
write the string in 16bit steps. Here is some code to illustrate the
$string = "";
$string .= chr(5);
$string .= chr(6);

the result will be a string containing these bytes: 05 00 06 00.
I want to access the string in an 8 bit scope, so that the result will be 05
If I enter data into the string using the [] operator, I have exactly the
same problem.

I'm using PHP 4.4.3RC2-dev

Thanks in advance,


Share this post

Link to post
Share on other sites
I'm not 100% sure on this, but I do have some thoughts:

1) If you have [url=http://uk2.php.net/manual/en/ref.mbstring.php]mbstring[/url] running with PHP, can you force it to 8-bit mode?
2) Would the [url=http://uk2.php.net/manual/en/language.operators.bitwise.php]Bitwise Operators[/url] be of any use you you here?

Share this post

Link to post
Share on other sites


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.