code: def encode_string(self, value):
          
          if not isinstance(value, str): return value
          try:
              return unicode(value, 'utf-8')
          except: # really, this should throw an exception.
                  # in the interest of not breaking current
                  # systems, however:
              arr = []
              for ch in value:
                  arr.append(unichr(ord(ch)))
              return u"".join(arr)
docs: Convert ASCII, Latin-1 or UTF-8 to pure Unicode