[interchange] Ensure that we use a UTF8 locale for strftime in [convert-date] tag.

Stefan Hornburg <[email protected]>
Newsgroups gmane.comp.web.interchange.cvs
Message-ID <[email protected]>
commit 8fd6ad78ee18174b556d953ca9ab52606b449acc
Author: Stefan Hornburg (Racke) <[email protected]>
Date:   Mon Mar 4 10:48:54 2013 +0100

    Ensure that we use a UTF8 locale for strftime in [convert-date] tag.
    Otherwise it causes a crash with "Malformed UTF-8 character".

 code/UserTag/convert_date.tag |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)
---
diff --git a/code/UserTag/convert_date.tag b/code/UserTag/convert_date.tag
index e91b908..4718f81 100644
--- a/code/UserTag/convert_date.tag
+++ b/code/UserTag/convert_date.tag
@@ -76,7 +76,13 @@ sub {
 	my $locale = $opt->{locale} || $Scratch->{mv_locale};
 	if ($locale) {
 		$current = POSIX::setlocale(&POSIX::LC_TIME);
-		POSIX::setlocale(&POSIX::LC_TIME, $locale);
+        if (($::Variable->{MV_UTF8} || $Global::Variable->{MV_UTF8})
+            && $locale !~ /\.utf8$/) {
+            POSIX::setlocale(&POSIX::LC_TIME, "$locale.utf8");
+        }
+        else {
+            POSIX::setlocale(&POSIX::LC_TIME, $locale);
+        }
 		$out = POSIX::strftime($fmt, @t);
 		POSIX::setlocale(&POSIX::LC_TIME, $current);
 	} else {
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.