Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Encoding issues - garbled japanese characters results after 'parse' function #37

Open
maksimlya opened this issue May 19, 2024 · 0 comments

Comments

@maksimlya
Copy link

Hi, I am having issues with my email client. Some users report garbled characters on their ends. Most of these users have non-standard text values. I have managed to reproduce the issue, but not sure how to tackle it. I saw some other tickets suggesting to use different methods, but they did not provide an example.

Here is a git with my issue:

https://github.com/maksimlya/emailjs-imap-handler-garbled-example

Can:
git clone
npm i
npm start

put a breakpoint at
console.log(res);

and see the 'Subject' text is garbled, altho I could read it correctly using TextDecoder.

This is the result I get from 'TextDecoder().decode(testVal):

* 17 FETCH (UID 27 BODY[HEADER.FIELDS (FROM TO CC BCC SUBJECT REPLY-TO MESSAGE-ID REFERENCES IN-REPLY-TO X-WELCOME X-WELCOME-EMAIL X-SSHIDE X-SSSINGLEHIDE DISPOSITION-NOTIFICATION-TO X-CONFIRM-READING-TO RETURN-RECEIPT-TO X-PRIORITY IMPORTANCE)] {81}\r\nFrom: [email protected]\nTo: [email protected]\nSubject: テストメール\n\r\n)

And this is the counter-part of that value after using parse function from this lib:

From: [email protected]\nTo: [email protected]\nSubject: ã��ã�¹ã��ã�¡ã�¼ã�«\n\r\n

Screenshot 2024-05-19 at 15 03 40

Any advice / solution?

I've tried to convert the Uint8Array to string, then converting it back with the 'suggested' method of using 'fromCharCode(0)', but that resulted with other errors of 'Unexpected char at position x', so I'm not quite sure what to do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant