Reputation: 141
My question:
In PHP it is easy to reference the single byte string, $single = "abc";
for example,
echo $single[0]; //"a"
However for the multibyte string $multi = "äåö"
, I get "nonsense", that is,
echo $multi[0]; //?
I know one can reference the individual letters of a multi byte string by coding as follows:
mb_internal_encoding("UTF-8");
echo mb_substr($multi,1,1);//which gives the right answer "å"
But isn't there an easier way to do this? I am especially looking for a way where I can reference the multi byte string with square brackets and just one parameter as for the single byte case.
Upvotes: 4
Views: 124
Reputation: 70500
No, Unicode support is on the table for new versions, but it is not ready yet. It will get there at some point presumably, but not yet.
A string is series of characters, where a character is the same as a byte. This means that PHP only supports a 256-character set, and hence does not offer native Unicode support.
The closest you could get to this is implementing an object implementing ArrayAccess
using a __toString()
function and a LOT of fiddling. Not recommended in my opinion.
Upvotes: 2