Jump to content

accesing string bytes


dodo

Recommended Posts

Hello,

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
problem:
$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
06.
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,

Oded.

Link to comment
https://forums.phpfreaks.com/topic/14925-accesing-string-bytes/
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?
Link to comment
https://forums.phpfreaks.com/topic/14925-accesing-string-bytes/#findComment-59873
Share on other sites

Archived

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

×
×
  • Create New...

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.