How do I capture utf-8 decode errors in node.js?
I just discovered that Node (tested: v0.8.23, current git: v0.11.3-pre) ignores any decoding errors in its Buffer handling, silently replacing any non-utf8 characters with
'ufffd' (the Unicode REPLACEMENT CHARACTER) instead of throwing an exception about the non-utf8 input. As a consequence,
process.stdin.setEncoding and friends mask a large class of bad input errors for you.