From: <svn...@ob...> - 2004-05-22 12:56:56
|
Author: tiran Date: Sat May 22 08:05:28 2004 New Revision: 5178 Modified: CMFPlone/branches/tiran-securemailhost-branch/PloneTool.py Log: Added utf8_portal and portal_utf8 methods to PloneTool Modified: CMFPlone/branches/tiran-securemailhost-branch/PloneTool.py ============================================================================== --- CMFPlone/branches/tiran-securemailhost-branch/PloneTool.py (original) +++ CMFPlone/branches/tiran-securemailhost-branch/PloneTool.py Sat May 22 08:05:28 2004 @@ -73,6 +73,7 @@ user=membership.getMemberById(member) user.setMemberProperties(properties) + security.declarePublic('getSiteEncoding') def getSiteEncoding(self): """Get the default_charset or fallback to utf8 """ @@ -84,6 +85,30 @@ charset = default return charset + security.declarePublic('portal_utf8') + def portal_utf8(self, str, errors='strict'): + """Transforms an string in portal encoding to utf8 + """ + charset = self.getSiteEncoding() + if charset.lower() in ('utf-8', 'utf8'): + # test + unicode(str, 'utf-8', errors) + return str + else: + return unicode(str, charset, errors).encode('utf-8', errors) + + security.declarePublic('utf8_portal') + def utf8_portal(self, str, errors='strict'): + """Transforms an utf8 string to portal encoding + """ + charset = self.getSiteEncoding() + if charset.lower() in ('utf-8', 'utf8'): + # test + unicode(str, 'utf-8', errors) + return str + else: + return unicode(str, 'utf-8', errors).encode(charset, errors) + security.declarePrivate('getMailHost') def getMailHost(self): """Get the MailHost |