Javascript unicode字符串在下载的html上被破坏
我将以html的形式下载该页面。 但当内容包含unicode字符串(如阿拉伯语或汉语)时,unicode字符串在下载的html中会被破坏Javascript unicode字符串在下载的html上被破坏,javascript,html,reactjs,Javascript,Html,Reactjs,我将以html的形式下载该页面。 但当内容包含unicode字符串(如阿拉伯语或汉语)时,unicode字符串在下载的html中会被破坏 newStyle.innerHTML = styleContent; //The content isn't broken here doc.head.appendChild(newStyle); doc.body.appendChild(newDiv); const tempEl = document.createElement('a'); tempEl.
newStyle.innerHTML = styleContent; //The content isn't broken here
doc.head.appendChild(newStyle);
doc.body.appendChild(newDiv);
const tempEl = document.createElement('a');
tempEl.href = 'data:text/plain;charset=utf-8,' + encodeURIComponent(doc.documentElement.innerHTML);
tempEl.target = '_blank';
tempEl.download = 'page.html';
tempEl.click();