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

German Umlauts or Emoji problem #898

Open
Flo0806 opened this issue Feb 26, 2023 · 0 comments
Open

German Umlauts or Emoji problem #898

Flo0806 opened this issue Feb 26, 2023 · 0 comments

Comments

@Flo0806
Copy link

Flo0806 commented Feb 26, 2023

Hello!

I use the standard example code like this:

 function openInbox(cb) {
    imap.openBox("INBOX", true, cb);
  }

  imap.once("ready", function () {
    openInbox(function (err, box) {
      if (err) throw err;
      var f = imap.seq.fetch("1:1", {
        bodies: ["HEADER.FIELDS (FROM TO SUBJECT DATE)", "TEXT"],
        struct: true,
      });
      f.on("message", function (msg, seqno) {
        console.log("Message #%d", seqno);
        var prefix = "(#" + seqno + ") ";
        msg.on("body", function (stream, info) {
          if (info.which === "TEXT")
            console.log(
              prefix + "Body [%s] found, %d total bytes",
              inspect(info.which),
              info.size
            );

          var buffer = "";

          stream.on("data", function (chunk) {
            buffer += chunk.toString("utf8");
          });
          stream.once("end", function () {
            if (info.which !== "TEXT")
              console.log(
                prefix + "Parsed header: %s",
                inspect(Imap.parseHeader(buffer, false, 10))
              );
            else {
              //   console.log(
              //     prefix + "Body [%s] Finished",
              //     inspect(info.which),
              //     buffer
              //   );
            }
          });
        });
        msg.once("attributes", function (attrs) {
          console.log(prefix + "Attributes: %s", inspect(attrs, false, 8));
        });
        msg.once("end", function () {
          console.log(prefix + "Finished");
        });
      });
      f.once("error", function (err) {
        console.log("Fetch error: " + err);
      });
      f.once("end", function () {
        console.log("Done fetching all messages!");
        imap.end();
      });
    });
  });

  imap.once("error", function (err) {
    console.log(err);
  });

  imap.once("end", function () {
    console.log("Connection ended");
  });

  imap.connect();
};

And the problem is that german umlauts or emoji are not shown like this:

(#1) Parsed header: {
  subject: [ 'Ein T├Âst' ],
  to: [ 'no-reply@flogersoft.de' ],
  from: [ '"Florian Heuberger" <fh@flogersoft.de>' ],
  date: [ 'Sun, 26 Feb 2023 00:42:20 +0100 (CET)' ]
}

The current subject name is "Ein Töst". What can I do to fix this?

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