]> 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:39:13 +0000 (13:39 +0000)
committergarvinhicking <garvinhicking>
Wed, 29 Mar 2006 13:39:13 +0000 (13:39 +0000)
docs/NEWS
include/functions.inc.php

index e359b9b30d002967da31a33763ec92b12967e816..63cefb43004f663d138f3af8f293eb2d6d666f10 100644 (file)
--- a/docs/NEWS
+++ b/docs/NEWS
@@ -3,6 +3,9 @@
 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 72dd02b2b8e06fec0c9f46de6ec6c65a31127d5b..8f729e4da4374dbb124090224378969f8d0ac4d4 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 'jalali-utf8':
             if ($timestamp == null) {
@@ -95,10 +102,16 @@ function serendipity_strftime($format, $timestamp = null, $useOffset = true) {
             }
 
             require_once S9Y_INCLUDE_PATH . 'include/functions_calendars.inc.php';
-            return jalali_strftime_utf($format, $timestamp);
+            $out = jalali_strftime_utf($format, $timestamp);
+            break;
+    }
+
+    if ($is_win_utf) {
+        $out = utf8_encode($out);
     }
-}
 
+    return $out;
+}
 /**
  * A wrapper function call for formatting Timestamps.
  *
@@ -373,7 +386,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 +426,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 +439,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';