node.jsencodingmultipartform-datamulter7-bit

Multer Encoding Issue: localized text getting converted random character


I am using multer's upload.single to extract a csv file from request. When converting the buffer given by multer's upload fn to string, I observed localized text characters (like À) are getting converted to some random character( like � ).The encoding which multer uses is 7bit. Is there any way to get data in utf-8 encoding.

contentType: multipart/form-data; boundary=--------------------------685735458832809176548913

Multer's file details:

fieldname: 'file',
originalname: 'Sample.csv',
encoding: '7bit',
mimetype: 'text/csv',

Solution

  • I found a solution to the issue, When converting the buffer to string add 'latin1' as encoding

    request.file.buffer.toString('latin1')