| @@ 164-171 (lines=8) @@ | ||
| 161 | * @param string $from source encoding |
|
| 162 | * @return string UTF-8 encoded string, original string if iconv failed. |
|
| 163 | */ |
|
| 164 | function I18N_toUTF8($string, $from) |
|
| 165 | { |
|
| 166 | if ($from != 'UTF-8') { |
|
| 167 | $s = iconv($from, 'UTF-8', $string); //to UTF-8 |
|
| 168 | return $s !== false ? $s : $string; //it could return false |
|
| 169 | } |
|
| 170 | return $string; |
|
| 171 | } |
|
| 172 | ||
| 173 | /** |
|
| 174 | * Convert UTF-8 strings to a different encoding. NB. The result |
|
| @@ 180-187 (lines=8) @@ | ||
| 177 | * @param string $to detination encoding |
|
| 178 | * @return string encoded string. |
|
| 179 | */ |
|
| 180 | function I18N_toEncoding($string, $to) |
|
| 181 | { |
|
| 182 | if ($to != 'UTF-8') { |
|
| 183 | $s = iconv('UTF-8', $to, $string); |
|
| 184 | return $s !== false ? $s : $string; |
|
| 185 | } |
|
| 186 | return $string; |
|
| 187 | } |
|
| 188 | ||