I have an old mysql database (mysql 5.0.2) in latin1 and I want to get data from it. For non-ascii characters I'm getting always the same output (eg., Â, À and Á are being presented as something like 'ef bf bd' in hex), that's to say different chars being presented the same way.
I just need to get these chars differently so I can map each one to the right corresponding utf-8 char.
I've already been trying to change the charset but it's not working for me!
Would someone please help me to get some data making sense?
var mysql = require('mysql')
var con = mysql.createConnection({
host: "localhost",
user: "root",
//charset: "utf8mb4",
//charset: "utf8",
charset: "latin1",
database : 'my_db'
})
con.connect()
var query = con.query("SELECT data from my_table where id='07'", function
(error, results, fields) {
var b = Buffer.from (results[0].data)
console.log ('Retrieved data in hex -> ', b)
})
con.end()
When I go to the db and update the data to some ascii-only string, I can get the data in js without any problem, but when I replace that data to something like 'á' or 'à', I get always 'ef bf bd' in hex (-17 -65 -67 in decimal).