encoding - Converting ISO-8859-1 to UTF-8 for MultipartFormData in Play2 + Scala when parsing email from Sendgrid -
i have hooked play2+scala application sendgrid parse api , i'm struggling in decoding , encoding content of email. since emails in different encodings sendgrid provides json object charsets: {"to":"utf-8","cc":"utf-8","subject":"utf-8","from":"utf-8","text":"iso-8859-1","html":"iso-8859-1"} in test case "text" "med vänliga hälsningar jakobs webshop" if extract multipart request , print out: logger.info(request.body.dataparts.get("text").get) i get: med v?nliga h?lsningar jakobs webshop ok given info sendgrid let's fix string utf-8 . def parsemail = action(parse.multipartformdata) { request => { val inputbuffer = request.body.dataparts.get("text").map { v => bytebuffer.wrap(v.head.getbytes()) } val fromcharset = charset.forname("iso-8859-1") val tochar...