瀏覽代碼

[ZF-9854] Zend_Filter:

- implemented usage of mb_internal_encoding

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@22790 44c647ce-9c0f-0410-b52a-842ac1e357ba
thomas 15 年之前
父節點
當前提交
c633946fd4

+ 4 - 0
library/Zend/Filter/StringToLower.php

@@ -57,6 +57,10 @@ class Zend_Filter_StringToLower implements Zend_Filter_Interface
             $options = $temp;
         }
 
+        if (!array_key_exists('encoding', $options) && function_exists('mb_internal_encoding')) {
+            $options['encoding'] = mb_internal_encoding();
+        }
+
         if (array_key_exists('encoding', $options)) {
             $this->setEncoding($options['encoding']);
         }

+ 4 - 0
library/Zend/Filter/StringToUpper.php

@@ -57,6 +57,10 @@ class Zend_Filter_StringToUpper implements Zend_Filter_Interface
             $options = $temp;
         }
 
+        if (!array_key_exists('encoding', $options) && function_exists('mb_internal_encoding')) {
+            $options['encoding'] = mb_internal_encoding();
+        }
+
         if (array_key_exists('encoding', $options)) {
             $this->setEncoding($options['encoding']);
         }

+ 12 - 0
tests/Zend/Filter/StringToLowerTest.php

@@ -169,4 +169,16 @@ class Zend_Filter_StringToLowerTest extends PHPUnit_Framework_TestCase
             $this->assertContains('mbstring is required', $e->getMessage());
         }
     }
+
+    /**
+     * @group ZF-9854
+     */
+    public function testDetectMbInternalEncoding()
+    {
+        if (!function_exists('mb_internal_encoding')) {
+            $this->markTestSkipped("Function 'mb_internal_encoding' not available");
+        }
+
+        $this->assertEquals(mb_internal_encoding(), $this->_filter->getEncoding());
+    }
 }

+ 12 - 0
tests/Zend/Filter/StringToUpperTest.php

@@ -169,4 +169,16 @@ class Zend_Filter_StringToUpperTest extends PHPUnit_Framework_TestCase
             $this->assertContains('mbstring is required', $e->getMessage());
         }
     }
+
+    /**
+     * @group ZF-9854
+     */
+    public function testDetectMbInternalEncoding()
+    {
+        if (!function_exists('mb_internal_encoding')) {
+            $this->markTestSkipped("Function 'mb_internal_encoding' not available");
+        }
+
+        $this->assertEquals(mb_internal_encoding(), $this->_filter->getEncoding());
+    }
 }