Jump to content


Photo

accesing string bytes


  • Please log in to reply
1 reply to this topic

#1 dodo

dodo
  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 18 July 2006 - 09:18 AM

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.



#2 Kris

Kris
  • Staff Alumni
  • Advanced Member
  • 2,755 posts
  • LocationThe Internet

Posted 18 July 2006 - 12:35 PM

I'm not 100% sure on this, but I do have some thoughts:

1) If you have mbstring running with PHP, can you force it to 8-bit mode?
2) Would the Bitwise Operators be of any use you you here?




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users