improve encoding utf8->ascii for non-printable chars
[plcapi.git] / tests / 0CharsetTest.php
index f94e3f4..549b0f4 100644 (file)
@@ -15,8 +15,9 @@ use PhpXmlRpc\Helper\Charset;
  *     chcp 28591 (latin1)
  *     chcp 65001 (utf8)
  *
- * @todo add tests for conversion: utf8 -> ascii
+ * @todo add tests for conversion: utf8 -> ascii (incl. chars 0-31)
  * @todo add tests for conversion: latin1 -> utf8
+ * @todo add tests for conversion: latin1 -> ascii
  */
 class CharsetTest extends PhpXmlRpc_PolyfillTestCase
 {
@@ -49,6 +50,15 @@ class CharsetTest extends PhpXmlRpc_PolyfillTestCase
         );
     }
 
+    protected function utf8ToAscii($data)
+    {
+        return Charset::instance()->encodeEntities(
+            $data,
+            'UTF-8',
+            'US-ASCII'
+        );
+    }
+
     public function testUtf8ToLatin1All()
     {
         /*$this->assertEquals(