Logo Search packages:      
Sourcecode: zope-cps-portaltransforms version File versions  Download package

def PortalTransforms::MimeTypesRegistry::MimeTypesRegistry::guess_encoding (   self,
  data 
)

Try to guess encoding from a text value if no encoding
guessed, used the default charset from site properties (Zope)
with a fallback to UTF-8 (should never happen with correct
site_properties, but always raise Attribute error without
Zope)

Definition at line 269 of file MimeTypesRegistry.py.

00269                                   :
        """ Try to guess encoding from a text value if no encoding
        guessed, used the default charset from site properties (Zope)
        with a fallback to UTF-8 (should never happen with correct
        site_properties, but always raise Attribute error without
        Zope)
        """
        if type(data) is type(u''):
            # data maybe unicode but with another encoding specified
            data = data.encode('UTF-8')
        encoding = guess_encoding(data)
        if encoding is None:
            try:
                site_props = self.portal_properties.site_properties
                encoding = site_props.getProperty('default_charset', 'UTF-8')
            except:
                encoding = 'UTF-8'
        return encoding

def split(name):


Generated by  Doxygen 1.6.0   Back to index