ZF-7279: Zend_Locale_Format::_parseDate fails when iconv internal encoding is not UTF-8

Issue Type: Bug Created: 2009-07-14T19:36:50.000+0000 Last Updated: 2010-01-12T13:08:29.000+0000 Status: Resolved Fix version(s): - 1.10.0 (27/Jan/10)

Reporter: C Snover (snover) Assignee: Thomas Weidner (thomas) Tags: - Zend_Locale

Related issues: - ZF-8781



Zend_Locale_Format::_parseDate assumes that iconv internal encoding is UTF-8 and performs operations against UTF-8 data from Zend_Locale. If the internal character encoding is something other than UTF-8, it fails.

The below patch fixes the failure, but isn't entirely complete; the function will still fail some of the iconv operations if $date is not a valid UTF-8 string. It should be converted to UTF-8 at the beginning of the function, but I don't have an idea on how best to accomplish this.


<pre class="highlight">
--- Format.php  (revision 16719)
+++ Format.php  (working copy)
@@ -665,6 +667,9 @@
         $number = $date; // working copy
         $result['date_format'] = $format; // save the format used to normalize $number (convenience)
         $result['locale'] = $options['locale']; // save the locale used to normalize $number (convenience)
+        $oldEncoding = iconv_get_encoding('internal_encoding');
+        iconv_set_encoding('internal_encoding', 'UTF-8');

         $day   = iconv_strpos($format, 'd');
         $month = iconv_strpos($format, 'M');
@@ -925,6 +930,7 @@

+        iconv_set_encoding('internal_encoding', $oldEncoding);
         return $result;


Posted by Thomas Weidner (thomas) on 2009-08-23T12:34:34.000+0000

Fixed with r17783

Have you found an issue?

See the Overview section for more details.


© 2006-2018 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.