Re: Can I use strings with some unicode characters as array keys?
| From: | Darren Cook | Date: | Sun, 31 Jul 2011 03:16:16 +0000 |
| Subject: | Re: Can I use strings with some unicode characters as array keys? | ||
| References: | 1 | Groups: | php.i18n |
| Request: | Send a blank email to php-i18n+get-1437@lists.php.net to get a copy of this message | ||
> PHP manual says that one should only use strings or integers as keys.
> Also I know that PHP doesn't speak unicode yet.
Depending on what you mean by speaking unicode; the mbstring extension
has worked well for everything I've ever needed to do with unicode, and
supports all the various unicode character sets.
> So - I was just wondering - when unicode characteres aare used in
> array key - does PHP strips them or affects them in any way?
I believe that string array keys are treated as binary strings, and
never modified. I couldn't find you a source, but I've always worked on
this assumption and never hit a problem. UTF-8 keys definitely work fine
(*); I'm also not aware of any max length the keys can have (meaning you
shouldn't have to worry about a multi-byte character getting truncated
in the middle).
Darren
*: Well, to fully qualify that, I may only ever have tried with
Japanese, Chinese, Arabic and European languages :-)
--
Darren Cook, Software Researcher/Developer
http://dcook.org/work/ (About me and my work)
http://dcook.org/blogs.html (My blogs and articles)