IMAP node and non-UTF encoding (iso-8859-2)

I’m trying to create an email parser for notifications. The problem is, that the notifications are send in HTML-only and they are using ISO-8859-2 encoding.

When I execute IMAP node with Resolved/Simple formats, here’s what I see in html property:

E-mail zostaďż˝ wygenerowany automatycznie, prosimy na niego nie odpowiadaďż˝.

With RAW I get:

E-mail zosta� wygenerowany automatycznie, prosimy na niego nie odpowiada�.

(RAW also mentions encoding: This is an S/MIME signed message ------271FA8CCD25A514291379894969B4570 Content-Type: text/html; charset=iso-8859-2 Content-Transfer-Encoding: 8bit Date: Thu, 22 Jun 2023 17:19:36 +0200)

In order to properly work with this, I need to convert to UTF-8:

E-mail został wygenerowany automatycznie, prosimy na niego nie odpowiadać.

How can I achieve that? I tried converting it with jschardet + iconv-lite, but when the data gets to the Code node, it has already become ASCII (that’s at least how jschardet detects it as)

I tried encoding this as following:

const iconv = require('iconv-lite');

let buffer = Buffer.from($json.raw, 'binary');
let decodedData = iconv.decode(buffer, 'ISO-8859-2');
console.log(decodedData);

And it’s still broken:

E-mail zostaý wygenerowany automatycznie, prosimy na niego nie odpowiadaý

Attempt on encoding Resolved/Simple yields:

E-mail zosta�|Ý wygenerowany automatycznie, prosimy na niego nie odpowiada�|Ý

At this point I’m leaning towards a conclusion that this is a bug in the IMAP node, which returns mangled/mojibaked outputs.

Hey @Shalak,

At the moment it doesn’t look like the imap node has support for decoding properly, I will take a look later today and see if this is a quick fix.

2 Likes

Any luck on the quick fix? Is there anything I can do to help?

Hi @Shalak :wave: @Jon is out today, but can post an update on Monday when he’s back :slight_smile:

Hey @Shalak,

I had a quick look and it wasn’t a quick fix as such so I have created an internal dev ticket to set aside some time to look into it.

1 Like

Hello!

Are there any updates on this one? Is there anything I can do to help?

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.