import codecs


def decode_and_escape(data):
  """Decodes utf-8 data, and escapes it appropriately to use in *.strings."""
  u_string = codecs.decode(data, 'utf-8')
  u_string = u_string.replace('\\', '\\\\')
  u_string = u_string.replace('"', '\\"')
  return u_string