処理が無効なutf-16符号化


const replacement = '\ufffd';
// https://gist.github.com/mathiasbynens/bbe7f870208abcfec860
const loneSurrogates = /[\uD800-\uDBFF](?![\uDC00-\uDFFF])|([^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/g;

// string sanitizes the given str by replacing invalid UTF-16 code unit
// sequences with the unicode replacement character. Returns a new string.
//  \ufffd           ,         
exports.string = function(str) {
    return str.replace(loneSurrogates, '$1' + replacement);
}
元のモジュール: https://github.com/felixge/node-unicode-sanitize/blob/master/index.js