← All changes
|
vendor/neitanod/forceutf8/src/ForceUTF8/Encoding.php
+8
-8
3.1.3
→
3.4.9
View file →
| @@ -192,13 +192,13 @@ | ||
| 192 | 192 | $max = self::strlen($text); |
| 193 | 193 | |
| 194 | 194 | $buf = ""; |
| 195 | 195 | for($i = 0; $i < $max; $i++){ |
| 196 | - $c1 = $text{$i}; | |
| 196 | + $c1 = $text[$i]; | |
| 197 | 197 | if($c1>="\xc0"){ //Should be converted to UTF8, if it's not UTF8 already |
| 198 | - $c2 = $i+1 >= $max? "\x00" : $text{$i+1}; | |
| 199 | - $c3 = $i+2 >= $max? "\x00" : $text{$i+2}; | |
| 200 | - $c4 = $i+3 >= $max? "\x00" : $text{$i+3}; | |
| 198 | + $c2 = $i+1 >= $max? "\x00" : $text[$i+1]; | |
| 199 | + $c3 = $i+2 >= $max? "\x00" : $text[$i+2]; | |
| 200 | + $c4 = $i+3 >= $max? "\x00" : $text[$i+3]; | |
| 201 | 201 | if($c1 >= "\xc0" & $c1 <= "\xdf"){ //looks like 2 bytes UTF8 |
| 202 | 202 | if($c2 >= "\x80" && $c2 <= "\xbf"){ //yeah, almost sure it's UTF8 already |
| 203 | 203 | $buf .= $c1 . $c2; |
| 204 | 204 | $i++; |
| @@ -229,9 +229,9 @@ | ||
| 229 | 229 | $cc1 = (chr(ord($c1) / 64) | "\xc0"); |
| 230 | 230 | $cc2 = (($c1 & "\x3f") | "\x80"); |
| 231 | 231 | $buf .= $cc1 . $cc2; |
| 232 | 232 | } |
| 233 | - } elseif(($c1 & "\xc0") == "\x80"){ // needs conversion | |
| 233 | + } elseif(($c1 & "\xc0") === "\x80"){ // needs conversion | |
| 234 | 234 | if(isset(self::$win1252ToUtf8[ord($c1)])) { //found in Windows-1252 special cases |
| 235 | 235 | $buf .= self::$win1252ToUtf8[ord($c1)]; |
| 236 | 236 | } else { |
| 237 | 237 | $cc1 = (chr(ord($c1) / 64) | "\xc0"); |
| @@ -295,9 +295,9 @@ | ||
| 295 | 295 | return str_replace(array_keys(self::$brokenUtf8ToUtf8), array_values(self::$brokenUtf8ToUtf8), $text); |
| 296 | 296 | } |
| 297 | 297 | |
| 298 | 298 | static function removeBOM($str=""){ |
| 299 | - if(substr($str, 0,3) == pack("CCC",0xef,0xbb,0xbf)) { | |
| 299 | + if(substr($str, 0,3) === pack("CCC",0xef,0xbb,0xbf)) { | |
| 300 | 300 | $str=substr($str, 3); |
| 301 | 301 | } |
| 302 | 302 | return $str; |
| 303 | 303 | } |
| @@ -332,9 +332,9 @@ | ||
| 332 | 332 | |
| 333 | 333 | public static function encode($encodingLabel, $text) |
| 334 | 334 | { |
| 335 | 335 | $encodingLabel = self::normalizeEncoding($encodingLabel); |
| 336 | - if($encodingLabel == 'ISO-8859-1') return self::toLatin1($text); | |
| 336 | + if($encodingLabel === 'ISO-8859-1') return self::toLatin1($text); | |
| 337 | 337 | return self::toUTF8($text); |
| 338 | 338 | } |
| 339 | 339 | |
| 340 | 340 | protected static function utf8_decode($text, $option = self::WITHOUT_ICONV) |
| @@ -343,9 +343,9 @@ | ||
| 343 | 343 | $o = utf8_decode( |
| 344 | 344 | str_replace(array_keys(self::$utf8ToWin1252), array_values(self::$utf8ToWin1252), self::toUTF8($text)) |
| 345 | 345 | ); |
| 346 | 346 | } else { |
| 347 | - $o = iconv("UTF-8", "Windows-1252" . ($option == self::ICONV_TRANSLIT ? '//TRANSLIT' : ($option == self::ICONV_IGNORE ? '//IGNORE' : '')), $text); | |
| 347 | + $o = iconv("UTF-8", "Windows-1252" . ($option === self::ICONV_TRANSLIT ? '//TRANSLIT' : ($option === self::ICONV_IGNORE ? '//IGNORE' : '')), $text); | |
| 348 | 348 | } |
| 349 | 349 | return $o; |
| 350 | 350 | } |
| 351 | 351 | } |