Bug #9528: Fix Windows-1258 conversion
authorMichael M Slusarz <slusarz@curecanti.org>
Thu, 20 Jan 2011 20:23:54 +0000 (13:23 -0700)
committerMichael M Slusarz <slusarz@curecanti.org>
Thu, 20 Jan 2011 20:26:04 +0000 (13:26 -0700)
Remove workaround for broken iconv() added here:

http://git.horde.org/co.php/framework/Util/Attic/String.php?sa=1&rt=horde&r=1.19

There's no PHP bug referenced, and I can't find any.  Adding this
extra character breaks Windows-1258 conversion.
If it was a bug in 2003, hopefully it has been fixed by now (all unit
tests pass).

framework/Util/lib/Horde/String.php
framework/Util/test/Horde/Util/StringTest.php

index cfc90a9..2bf823a 100644 (file)
@@ -144,16 +144,13 @@ class Horde_String
 
         /* Try iconv with transliteration. */
         if (Horde_Util::extensionExists('iconv')) {
-            /* We need to tack an extra character temporarily because of a bug
-             * in iconv() if the last character is not a 7 bit ASCII
-             * character. */
             unset($php_errormsg);
             ini_set('track_errors', 1);
-            $out = @iconv($from, $to . '//TRANSLIT', $input . 'x');
+            $out = @iconv($from, $to . '//TRANSLIT', $input);
             $errmsg = isset($php_errormsg);
             ini_restore('track_errors');
             if (!$errmsg) {
-                return self::substr($out, 0, -1, $to);
+                return $out;
             }
         }
 
index 0c55d21..0600492 100644 (file)
@@ -450,4 +450,13 @@ EOT
         $this->assertEquals('foo', Horde_String::common('foobar', 'fooxyx'));
         $this->assertEquals('foo', Horde_String::common('foo', 'foobar'));
     }
+
+    public function testBug9528()
+    {
+        $this->assertEquals(
+            "<html>",
+            Horde_String::convertCharset("<html>", 'UTF-8', 'Windows-1258')
+        );
+    }
+
 }