Fix utf8_encode for shift_jis (problem with chars between 160 and 223)
authorMartin Kutschker <martin.t.kutschker@blackbox.net>
Fri, 25 Feb 2005 11:43:05 +0000 (11:43 +0000)
committerMartin Kutschker <martin.t.kutschker@blackbox.net>
Fri, 25 Feb 2005 11:43:05 +0000 (11:43 +0000)
Fix bug #576 (case conversion with mbstring)

git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@569 709f56b5-9817-0410-a4d7-c38de5d9e867

t3lib/class.t3lib_cs.php

index 6983a0f..2de14df 100755 (executable)
@@ -649,14 +649,12 @@ class t3lib_cs {
                                        } else $outStr.=chr($this->noCharByteVal);      // No char exists
                                        $a++;
                                } elseif ($ord>127)     {       // If char has value over 127 it's a multibyte char in UTF-8
-                                       if ($charset == 'shift_jis' && ($ord <160 || $ord>223)) {       // Shift-JIS is like EUC, but chars between 160 and 223 are single byte
-                                               $a++;
-                                               $ord2 = ord(substr($str,$a,1));
-                                               $ord = $ord*256+$ord2;
-                                       } elseif (isset($this->eucBasedSets[$charset])) {       // EUC uses two-bytes above 127; we get both and advance pointer and make $ord a 16bit int.
-                                               $a++;
-                                               $ord2 = ord(substr($str,$a,1));
-                                               $ord = $ord*256+$ord2;
+                                       if (isset($this->eucBasedSets[$charset]))       {       // EUC uses two-bytes above 127; we get both and advance pointer and make $ord a 16bit int.
+                                               if ($charset != 'shift_jis' || ($ord < 0xA0 || $ord > 0xDF))    {       // Shift-JIS: chars between 160 and 223 are single byte
+                                                       $a++;
+                                                       $ord2=ord(substr($str,$a,1));
+                                                       $ord = $ord*256+$ord2;
+                                               }
                                        }
 
                                        if (isset($this->parsedCharsets[$charset]['local'][$ord]))      {       // If the local char-number was found in parsed conv. table then we use that, otherwise 127 (no char?)
@@ -1500,9 +1498,9 @@ class t3lib_cs {
        function conv_case($charset,$string,$case)      {
                if ($GLOBALS['TYPO3_CONF_VARS']['SYS']['t3lib_cs_utils'] == 'mbstring' && float(phpversion()) >= 4.3)   {
                        if ($case == 'toLower') {
-                               return mb_strtolower($str,'utf-8');
+                               return mb_strtolower($string,'utf-8');
                        } else {
-                               return mb_strtoupper($str,'utf-8');
+                               return mb_strtoupper($string,'utf-8');
                        }
                } elseif ($charset == 'utf-8')  {
                        return $this->utf8_char_mapping($string,'case',$case);
@@ -2049,4 +2047,4 @@ class t3lib_cs {
 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_cs.php'])       {
        include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_cs.php']);
 }
-?>
+?>
\ No newline at end of file