Closed
Description
We have JSON Type data field with some Latin characters, for example: "açaí". We used to use node-mysql, which queries the JSON filed as String, and we use JSON.parse to get the JSON object, which returns the correct character set, i.e. "açaí".
We switched to node-mysql2, and used typeCast
to skip auto JSON parsing, like this:
typeCast: (field, next) => {
if (field.type === 'JSON') {
return field.string();
}
return next();
}
Everything works fine, but it does not handle encoding correctly, in the case, "açaí" is displayed as "açaÃ".
I am wondering how field.string(
) works. Does it use "UTF-8"? Can we return the JSON field using String as node-mysql does?
Metadata
Metadata
Assignees
Labels
No labels