Encode special characters found in string I{s}.
        @param s: A string to encode.
        @type s: str
        @return: The encoded string.
        @rtype: str
1102
def encode(self, s):
        
        if isinstance(s, str) and self.needsEncoding(s):
            for x in self.encodings:
                s = re.sub(x[0], x[1], s)
        return s
637249
def _encode_string(s):
        
        if six.PY2 and isinstance(s, unicode):
            return s.encode('utf-8')
        return s
417655
def recode_unicode(s, encoding='utf-8'):
    
    if isinstance(s, str):
        return s.encode().decode(encoding)
    return s
896006
def fsencoding(s, encoding=sys.getfilesystemencoding()):
    
    if isinstance(s, unicode):
        s = s.encode(encoding)
    return s
374770
def encode(cls, s):
        
        b = ByteString(s)
        be = base64.b64encode(b).strip()
        return String(be)
891205
def encode_basestring(s, _PY3=PY3, _q=u('"')):
    
    if _PY3:
        if isinstance(s, binary_type):
            s = s.decode('utf-8')
    else:
        if isinstance(s, str) and HAS_UTF8.search(s) is not None:
            s = s.decode('utf-8')
    def replace(match):
        return ESCAPE_DCT[match.group(0)]
    return _q + ESCAPE.sub(replace, s) + _q
814492
def encode(s)
      return s if s.nil?
      return s if s.valid_encoding?
      if s.force_encoding("iso-8859-1").valid_encoding?
        return s.encode('utf-8', 'iso-8859-1')
      end
      s
    end
1259522
def to_str(s):
    
    if isinstance(s, bytes):
        s = s.decode('utf-8')
    elif not isinstance(s, str):
        s = str(s)
    return s
1250388
function encodeSpecialCharacters (str) {
  return encodeURI(str).replace(/[!'()* ]/g, function (char) {
    return '%' + char.charCodeAt(0).toString(16)
  })
}
1174163
public static String decodeUnicodeString(String s) {
    if (Strings.isNullOrEmpty(s)) return s;

    int length = s.length();
    StringBuilder sb = new StringBuilder(length);
    Matcher m = UNICODE_PATTERN.matcher(s);
    int begin = 0;
    while (m.find()) {
      int start = m.start();
      if (start > 0 && s.charAt(start - 1) == '\u0003') {
        if (start - 1 > begin) {
          sb.append(s, begin, start - 1);
        }
        begin = start;
        continue;
      }
      sb.append(s, begin, start);
      String mcStr = m.group(1);
      try {
        char charValue = (char) Integer.parseInt(mcStr, 16);
        sb.append(charValue);
        begin = m.end();
      } catch (NumberFormatException e) {
        System.out.println(e.getMessage());
      }
    }

    if (begin < length) {
      sb.append(s, begin, length);
    }
    return sb.toString();
  }
709267
def encode(string):
		

		result=".".join([ str(ord(s)) for s in string ])
		return  "%s." % (len(string)) + result
225057
def encode_character(char):
    
    if char == '!': return '%21'
    elif char == '"': return '%22'
    elif char == '#': return '%23'
    elif char == '$': return '%24'
    elif char == '%': return '%25'
    elif char == '&': return '%26'
    elif char == '\'': return '%27'
    elif char == '(': return '%28'
    elif char == ')': return '%29'
    elif char == '*': return '%2A'
    elif char == '+': return '%2B'
    elif char == ',': return '%2C'
    elif char == '-': return '%2D'
    elif char == '.': return '%2E'
    elif char == '/': return '%2F'
    elif char == ':': return '%3A'
    elif char == ';': return '%3B'
    elif char == '<': return '%3C'
    elif char == '=': return '%3D'
    elif char == '>': return '%3E'
    elif char == '?': return '%3F'
    elif char == '@': return '%40'
    elif char == '[': return '%5B'
    elif char == '\\': return '%5C'
    elif char == ']': return '%5D'
    elif char == '^': return '%5E'
    elif char == '_': return '%5F'
    elif char == '`': return '%60'
    elif char == '{': return '%7B'
    elif char == '|': return '%7C'
    elif char == '}': return '%7D'
    elif char == '~': return '%7E'
    elif char == ' ': return '%7F'
    else: return char
1088351
def to_str(s, encoding=None, errors='strict'):
    
    encoding = encoding or 'utf-8'

    if is_strlike(s):
        if six.PY2:
            return s.encode(encoding, errors) if isinstance(s, unicode) else s
        else:
            return s.decode(encoding, errors) if isinstance(s, bytes) else s
    else:
        return str(s)
92579
def encode(s):
    
    if not isinstance(s, text_type):
        return s

    r = []
    _in = []

    def extend_result_if_chars_buffered():
        if _in:
            r.extend(['&', modified_utf7(''.join(_in)), '-'])
            del _in[:]

    for c in s:
        if ord(c) in PRINTABLE:
            extend_result_if_chars_buffered()
            r.append(c)
        elif c == '&':
            extend_result_if_chars_buffered()
            r.append('&-')
        else:
            _in.append(c)

    extend_result_if_chars_buffered()

    return ''.join(r)
313609
def _string_to_int(self, s):
        
        base = len(self.alphabet)
        return sum((self._letter_to_int(l) * base**lsb 
                    for lsb, l in enumerate(s)
                   ))
767994
def decode(cls, s):
        
        b = ByteString(s)
        bd = base64.b64decode(b)
        return String(bd)
665682
def encodeSpecialChars(self, input):
        
        ret = libxml2mod.xmlEncodeSpecialChars(self._o, input)
        return ret