code: def encode(self, string):
          
          if isinstance(string, unicode):
              string = string.encode("utf-8")
          return quote(string, safe="~")
docs: Encode a_string as per the canonicalisation encoding rules.
  
          See the AWS dev reference page 186 (2009-11-30 version).
          @return: a_string encoded.