Window.open () opens the txt file with garbled Chinese characters.

opening the txt file with the following code in the js code will cause Chinese garbled. Is there any solution?

let newWin = window.open("_blank");
newWin.location = "a.txt";
//newWin.document.charset="UTF-8";
console.log("88888:",newWin.document.charset)
newWin.document.characterSet="UTF-8";

uses several attribute assignments such as charset, but attributes such as charset are read-only, so this approach has no effect.

Mar.12,2021

var newUrl= "data:text/html;charset=utf-8," + encodeURI (url). Replace (/-sharp/g, "% 23");
window.open (newUrl);


set header ('Content-Type: text/plain; charset=utf-8') on the backend.
or don't open it on a new page, just insert the contents of the txt file in the current page with the

 or  tag. 


Brother, how did you solve it?

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b227db-2ab67.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b227db-2ab67.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?