Back to index

plone3  3.1.7
Classes | Functions
kss.core.unicode_quirks Namespace Reference


class  KSSUnicodeError


def force_unicode

Class Documentation

class kss::core::unicode_quirks::KSSUnicodeError

Definition at line 18 of file

Function Documentation

def kss.core.unicode_quirks.force_unicode (   value,
  encoding = 'ascii' 

Definition at line 21 of file

00022 def force_unicode(value, encoding='ascii'):
00023     'Force value to be unicode - allow also value in a specific encoding (by default, ascii).'
00024     if isinstance(value, str):
00025         try:
00026             value = unicode(value, encoding)
00027         except UnicodeDecodeError, exc:
00028             raise KSSUnicodeError, 'Content must be unicode or ascii string, original exception: %s' % (exc, )
00029     else:
00030         assert isinstance(value, unicode)
00031     return value

Here is the caller graph for this function: