From 6e8ad01e982d2f7a983fffbcfa51885d6879d967 Mon Sep 17 00:00:00 2001 From: garvinhicking Date: Wed, 29 Mar 2006 13:38:57 +0000 Subject: [PATCH] Fix missing UTF-8 encoding of date locales on Windows setups --- docs/NEWS | 3 +++ include/functions.inc.php | 26 ++++++++++++++++++++------ 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/docs/NEWS b/docs/NEWS index 70fc452..a3e34cd 100644 --- 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) diff --git a/include/functions.inc.php b/include/functions.inc.php index dacc7e1..14cb074 100644 --- a/include/functions.inc.php +++ b/include/functions.inc.php @@ -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'; -- 2.39.5