The goog.i18n.mime Namespace

.encode(str, opt_noquote)

Encodes a string for inclusion in a MIME header. The string is encoded in UTF-8 according to RFC 1522, using quoted-printable form.

str {string}
The string to encode.
opt_noquote {boolean=}
Whether double-quote characters should also be escaped (should be true if the result will be placed inside a quoted string for a parameter value in a MIME header).
returns {string}
The encoded string.