← All changes
|
vendor/neitanod/forceutf8/src/ForceUTF8/Encoding.php
+9
-13
3.1.0
→
3.0.10
View file →
| @@ -182,16 +182,16 @@ | ||
| 182 | 182 | { |
| 183 | 183 | $text[$k] = self::toUTF8($v); |
| 184 | 184 | } |
| 185 | 185 | return $text; |
| 186 | - } | |
| 187 | - | |
| 186 | + } | |
| 187 | + | |
| 188 | 188 | if(!is_string($text)) { |
| 189 | 189 | return $text; |
| 190 | 190 | } |
| 191 | - | |
| 191 | + | |
| 192 | 192 | $max = self::strlen($text); |
| 193 | - | |
| 193 | + | |
| 194 | 194 | $buf = ""; |
| 195 | 195 | for($i = 0; $i < $max; $i++){ |
| 196 | 196 | $c1 = $text{$i}; |
| 197 | 197 | if($c1>="\xc0"){ //Should be converted to UTF8, if it's not UTF8 already |
| @@ -257,14 +257,14 @@ | ||
| 257 | 257 | return $text; |
| 258 | 258 | } |
| 259 | 259 | } |
| 260 | 260 | |
| 261 | - static function toISO8859($text, $option = self::WITHOUT_ICONV) { | |
| 262 | - return self::toWin1252($text, $option); | |
| 261 | + static function toISO8859($text) { | |
| 262 | + return self::toWin1252($text); | |
| 263 | 263 | } |
| 264 | 264 | |
| 265 | - static function toLatin1($text, $option = self::WITHOUT_ICONV) { | |
| 266 | - return self::toWin1252($text, $option); | |
| 265 | + static function toLatin1($text) { | |
| 266 | + return self::toWin1252($text); | |
| 267 | 267 | } |
| 268 | 268 | |
| 269 | 269 | static function fixUTF8($text, $option = self::WITHOUT_ICONV){ |
| 270 | 270 | if(is_array($text)) { |
| @@ -273,12 +273,8 @@ | ||
| 273 | 273 | } |
| 274 | 274 | return $text; |
| 275 | 275 | } |
| 276 | 276 | |
| 277 | - if(!is_string($text)) { | |
| 278 | - return $text; | |
| 279 | - } | |
| 280 | - | |
| 281 | 277 | $last = ""; |
| 282 | 278 | while($last <> $text){ |
| 283 | 279 | $last = $text; |
| 284 | 280 | $text = self::toUTF8(static::utf8_decode($text, $option)); |
| @@ -336,9 +332,9 @@ | ||
| 336 | 332 | if($encodingLabel == 'ISO-8859-1') return self::toLatin1($text); |
| 337 | 333 | return self::toUTF8($text); |
| 338 | 334 | } |
| 339 | 335 | |
| 340 | - protected static function utf8_decode($text, $option = self::WITHOUT_ICONV) | |
| 336 | + protected static function utf8_decode($text, $option) | |
| 341 | 337 | { |
| 342 | 338 | if ($option == self::WITHOUT_ICONV || !function_exists('iconv')) { |
| 343 | 339 | $o = utf8_decode( |
| 344 | 340 | str_replace(array_keys(self::$utf8ToWin1252), array_values(self::$utf8ToWin1252), self::toUTF8($text)) |