'Encode special characters found in string I{s}.
@param s: A string to encode.
@type s: str
@return: The encoded string.
@rtype: str'

def encode(self, s):

    if (isinstance(s, basestring) and self.needsEncoding(s)):
        for x in self.encodings:
            s = re.sub(x[0], x[1], s)
    return s
