@@ -84,13 +84,16 @@ |
||
| 84 | 84 | { |
| 85 | 85 | // find all multi-byte characters (cf. utf-8 encoding specs) |
| 86 | 86 | $matches = array(); |
| 87 | - if (!preg_match_all('/[\xC0-\xF7][\x80-\xBF]+/', $str, $matches)) |
|
| 88 | - return $str; // plain ascii string |
|
| 87 | + if (!preg_match_all('/[\xC0-\xF7][\x80-\xBF]+/', $str, $matches)) { |
|
| 88 | + return $str; |
|
| 89 | + } |
|
| 90 | + // plain ascii string |
|
| 89 | 91 | |
| 90 | 92 | // update the encoding map with the characters not already met |
| 91 | - foreach ($matches[0] as $mbc) |
|
| 92 | - if (!isset($map[$mbc])) |
|
| 93 | + foreach ($matches[0] as $mbc) { |
|
| 94 | + if (!isset($map[$mbc])) |
|
| 93 | 95 | $map[$mbc] = chr(128 + count($map)); |
| 96 | + } |
|
| 94 | 97 | |
| 95 | 98 | // finally remap non-ascii characters |
| 96 | 99 | return strtr($str, $map); |