Losing unicode during passing unicode char
<p>I want to store in array pairs of unicode chars (char, number of instances of the char), but I have some problem with passing unicode chars:</p>

<p>This code:</p>

<pre><code>$str = 'ółś';

var_dump(str_split($str));
</code></pre>

<p>displays: </p>

<pre><code>array(6) {
  [0]=&gt;
  string(1) "�"
  [1]=&gt;
  string(1) "�"
  [2]=&gt;
  string(1) "�"
  [3]=&gt;
  string(1) "�"
  [4]=&gt;
  string(1) "�"
  [5]=&gt;
  string(1) "�"
}
</code></pre>

<p>And i don't understand what's wrong</p>

<p>But this code:</p>

<pre><code>$arr = array('ó' =&gt; 1, 'ł' =&gt; 1, 'ś' =&gt; 1);
var_dump($arr);
</code></pre>

<p>displays:</p>

<pre><code>array(3) {
  ["ó"]=&gt;
  int(1)
  ["ł"]=&gt;
  int(1)
  ["ś"]=&gt;
  int(1)
}
</code></pre>

<p>and for me it is a result, which I want to achive.</p>

<p><strong>EDIT:</strong></p>

<p>Replacement for str_split (length=1) for unicode chars:</p>

<pre><code>function mb_str_split( $string ) {
    # Split at all position not after the start: ^
    # and not before the end: $
    return preg_split('/(?&lt;!^)(?!$)/u', $string );
} 
</code></pre>

<p><a href="http://fr2.php.net/manual/en/function.mb-split.php#99851" rel="nofollow">source</a></p>
