| @@ -221,12 +221,9 @@ | ||
| 221 | 221 | ); |
| 222 | 222 | } |
| 223 | 223 | break; |
| 224 | 224 | case 'string': |
| 225 | - // condition introduced for Issue with non-English text #240 where languages such as Hebrew get messed up. | |
| 226 | - if ( function_exists( 'mb_detect_encoding' ) && mb_detect_encoding( $data[ $i ] ) !== 'UTF-8' ) { | |
| 227 | - $data[ $i ] = utf8_encode( $data[ $i ] ); | |
| 228 | - } | |
| 225 | + $data[ $i ] = $this->toUTF8( $data[ $i ] ); | |
| 229 | 226 | break; |
| 230 | 227 | } |
| 231 | 228 | } |
| 232 | 229 | |
| @@ -231,7 +228,24 @@ | ||
| 231 | 228 | } |
| 232 | 229 | |
| 233 | 230 | // error_log(print_r($data,true)); |
| 234 | 231 | return $data; |
| 232 | + } | |
| 233 | + | |
| 234 | + | |
| 235 | + /** | |
| 236 | + * Converts values to UTF8, if required. | |
| 237 | + * | |
| 238 | + * @access protected | |
| 239 | + * | |
| 240 | + * @param string $datum The data to convert. | |
| 241 | + * | |
| 242 | + * @return string The converted data. | |
| 243 | + */ | |
| 244 | + protected final function toUTF8( $datum ) { | |
| 245 | + if ( ! function_exists( 'mb_detect_encoding' ) || mb_detect_encoding( $datum ) !== 'ASCII' ) { | |
| 246 | + $datum = \ForceUTF8\Encoding::toUTF8( $datum ); | |
| 247 | + } | |
| 248 | + return $datum; | |
| 235 | 249 | } |
| 236 | 250 | |
| 237 | 251 | } |