andris9/encoding — pull request #12 by maxogden (2014-11-08 12:41:17+00:00)
Title: write errors to STDERR instead of STDOUT

I ran into an issue where:

- I was parsing an html email with an invalid charset (``), which caused [_detectHTMLCharset](https://github.com/andris9/mailparser/blob/master/lib/mailparser.js#L1387) to return `3DUTF-8` as the detected charset
- This caused iconv to throw inside [convert](https://github.com/andris9/encoding/blob/master/lib/encoding.js#L26) which writes the error to STDOUT
- This means [mbox-stream](https://www.npmjs.org/package/mbox-stream) writes invalid output to STDOUT. It is supposed to only write JSON to STDOUT but currently the `encoding` module is violating the UNIX rule of silence by writing directly to STDOUT. This addresses the issue by writing to STDERR instead.

A more ideal solution would be for the encoding module to pass the error back rather than simply printing it directly, but this is a quicker duct-tape style fix