Preserving newline characters in data:text URI

扶醉桌前 提交于 2019-12-01 09:20:43

My recommended solution is to not use Notepad, because it does not recognize non-Windows line formats. If you still want to be able to use Notepad with your output, replace all line feeds (0x0A) with carriage return+line feed pairs (0x0D 0x0A).

chrome.tabs.create({
    url: 'data:text;base64,' + btoa(data.replace(/\n/g, '\r\n')),
    active: false
});
mikevinmike

For all who try to preserve newline characters in a data URI without base64 encryption: this is not possible, you have to use base64 encoding.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!