From eea6c7477d348e0a12fed89a7d38763c42621977 Mon Sep 17 00:00:00 2001 From: renhbo Date: Fri, 19 Aug 2011 02:19:44 +0800 Subject: [PATCH] Fix an unicode error on Windows platform. --- pelican/contents.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pelican/contents.py b/pelican/contents.py index b7bc2502..d0859a96 100644 --- a/pelican/contents.py +++ b/pelican/contents.py @@ -3,6 +3,7 @@ from pelican.utils import slugify, truncate_html_words from pelican.log import * from pelican.settings import _DEFAULT_CONFIG from os import getenv +from sys import platform, stdin class Page(object): """Represents a page @@ -78,8 +79,11 @@ class Page(object): self.date_format = settings['DEFAULT_DATE_FORMAT'] if hasattr(self, 'date'): - self.locale_date = self.date.strftime(self.date_format.encode('ascii','xmlcharrefreplace')).decode('utf') - + if platform == 'win32': + self.locale_date = self.date.strftime(self.date_format.encode('ascii','xmlcharrefreplace')).decode(stdin.encoding) + else: + self.locale_date = self.date.strftime(self.date_format.encode('ascii','xmlcharrefreplace')).decode('utf') + # manage summary if not hasattr(self, 'summary'): self.summary = property(lambda self: truncate_html_words(self.content, 50)).__get__(self, Page)