code: def pct_encode(s, encdct):
      
      if s is None:
          return None
      elif not isinstance(s, unicode):
          s = str(s)
      else:
          s = s.encode('utf8')
  
      return ''.join(map(encdct.__getitem__, s))
docs: Return a translated version of s where each character is mapped to a
      string thanks to the encdct dictionary.
  
      Use the encdct parameter to construct a string from parameter s where
      each character k from s is replaced by the value corresponding to key k
      in encdct.  It happens that callers use dictionaries smartly
      constructed so that this function will perform percent-encoding quickly
      when called whith such a dictionary.