Answer the question
In order to leave comments, you need to log in
Problem with encoding when parsing and writing to the database (PHP)?
There is a task to parse goods from the site into the database (mariadb, database encoding utf8mb4). Using JS, we get a JSON file with UTF-8 encoding. Site in Russian. The code that writes to the file:
let productString = JSON.stringify(productArr);
let link = document.createElement('a');
var txtData = 'data:text/plain;charset=utf-8,' + encodeURIComponent(productString);
link.href = txtData;
link.target = '_blank';
link.download = 'filename.txt';
link.click();
Answer the question
In order to leave comments, you need to log in
Check the format for sending json data, check the connection format so that it is utf-8 and see if the document you use for JSON always has troubles like this, just do JSON.parse and everything will be ok
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question