]> git.mjollnir.org Git - s9y.git/commitdiff
Fix missing UTF-8 encoding of date locales on Windows setups
authorgarvinhicking <garvinhicking>
Wed, 29 Mar 2006 13:38:57 +0000 (13:38 +0000)
committergarvinhicking <garvinhicking>
Wed, 29 Mar 2006 13:38:57 +0000 (13:38 +0000)
docs/NEWS
include/functions.inc.php

index 70fc452bf84abb850723d4c372c99550f7201c07..a3e34cd8999633ccec47a784fd5679816f661359 100644 (file)
--- a/docs/NEWS
+++ b/docs/NEWS
@@ -42,6 +42,9 @@ Version 1.1-alpha1()
 Version 1.0 ()
 ------------------------------------------------------------------------
 
+   * Fix missing UTF-8 encoding of date locales on Windows setups
+     (garvinhicking)
+
    * Fix imagepng() function call for PHP 5.1.0 versions
      (Sebastian Mordziol)
 
index dacc7e173879fd104c94ea437ffde934addedaaf..14cb074287706cddce73a099e71d136415a3ab30 100644 (file)
@@ -76,6 +76,12 @@ function serendipity_serverOffsetHour($timestamp = null, $negative = false) {
  */
 function serendipity_strftime($format, $timestamp = null, $useOffset = true) {
     global $serendipity;
+    static $is_win_utf = null;
+
+    if ($is_win_utf === null) {
+        // Windows does not have UTF-8 locales.
+        $is_win_utf = (LANG_CHARSET == 'UTF-8' && strtoupper(substr(PHP_OS, 0, 3)) === 'WIN' ? true : false);
+    }
 
     switch($serendipity['calendar']) {
         default:
@@ -85,7 +91,8 @@ function serendipity_strftime($format, $timestamp = null, $useOffset = true) {
             } elseif ($useOffset) {
                 $timestamp = serendipity_serverOffsetHour($timestamp);
             }
-            return strftime($format, $timestamp);
+            $out = strftime($format, $timestamp);
+            break;
 
         case 'persian-utf8':
             if ($timestamp == null) {
@@ -95,8 +102,15 @@ function serendipity_strftime($format, $timestamp = null, $useOffset = true) {
             }
 
             require_once S9Y_INCLUDE_PATH . 'include/functions_calendars.inc.php';
-            return persian_strftime_utf($format, $timestamp);
+            $out = persian_strftime_utf($format, $timestamp);
+            break;
     }
+
+    if ($is_win_utf) {
+        $out = utf8_encode($out);
+    }
+
+    return $out;
 }
 
 /**
@@ -373,7 +387,7 @@ function serendipity_sendMail($to, $subject, $message, $fromMail, $headers = NUL
     if (is_null($fromMail) || empty($fromMail)) {
         $fromMail = $to;
     }
-    
+
     if (is_null($headers)) {
         $headers = array();
     }
@@ -413,8 +427,8 @@ function serendipity_sendMail($to, $subject, $message, $fromMail, $headers = NUL
             $maildata['subject'] = str_replace(array("\n", "\r"), array('', ''), mb_encode_mimeheader($maildata['subject'], LANG_CHARSET));
             $maildata['fromName'] = str_replace(array("\n", "\r"), array('', ''), mb_encode_mimeheader($maildata['fromName'], LANG_CHARSET));
         }
-    
-    
+
+
         // Always add these headers
         if (!empty($maildata['blogMail'])) {
             $maildata['headers'][] = 'From: "'. $maildata['fromName'] .'" <'. $maildata['blogMail'] .'>';
@@ -426,7 +440,7 @@ function serendipity_sendMail($to, $subject, $message, $fromMail, $headers = NUL
         $maildata['headers'][] = 'MIME-Version: 1.0';
         $maildata['headers'][] = 'Precedence: bulk';
         $maildata['headers'][] = 'Content-Type: text/plain; charset=' . LANG_CHARSET;
-        
+
         if (LANG_CHARSET == 'UTF-8') {
             if (function_exists('imap_8bit')) {
                 $maildata['headers'][] = 'Content-Transfer-Encoding: quoted-printable';