I have a csv that I get from my supplier, They have encoded a string with UTF-8 which now includes black question marks. I try to convert it back but am having no luck.
var common = require('./common/index.js');
var fs = require('fs');
var Iconv = require('iconv').Iconv;
var encoding = require('encoding');
var iconv = new Iconv('UTF-8', 'ISO-8859-1');
var detectCharacterEncoding = require('detect-character-encoding');
common.fileHandler(
'default.csv',
function(dataSet) {
var fileBuffer = fs.readFileSync('file.txt');
var charsetMatch = detectCharacterEncoding(fileBuffer);
console.log(charsetMatch);
console.log(encoding.convert(dataSet[0].description, 'UTF-8', 'ISO-8859-1'))
}
)
returns
{ encoding: 'UTF-8', confidence: 100 }
<Buffer c3 bd 20 53 79 6e 63 20 64 61 74 61 20 61 6e 64 20 66 61 73 74 20 63 68 61 72 67 69 6e 67 3c 62 72 2f 3e c3 bd 20 50 72 65 6d 69 75 6d 20 61 6c 75 6d 69 ...>
any help greatly appreciated
if you don't have original file (before conversion) and you tried everything but with no results you can always replace your question marks with proper utf8 characters :)
just copy question mark and paste it in your code (copy in your editor)
someContent.replace('paste_question_mark_here','ą');
this is last hope if you loose your encoding data after conversion