Next / Previous / Contents / Shipman's homepage

9.3. KwicIndex.__makeUni(): Force Unicode representation

kwic.py
# - - -   K w i c I n d e x . _ _ m a k e U n i

    def __makeUni(self, s):
        '''Force s to Unicode representation.

          [ if type(s) is unicode ->
              return s
            else if s is legal UTF-8 ->
              return s converted to Unicode using UTF-8
            else ->
              raise UnicodeEncodeError ]
        '''
        if type(s) is unicode:
            return s
        else:
            return unicode(s, 'utf-8')