js-visualizer-9000-client icon indicating copy to clipboard operation
js-visualizer-9000-client copied to clipboard

I can't copy the code to the page

Open lm101845 opened this issue 2 years ago • 2 comments

When I copy the code to the page, the website is clean and the console displays the following error message:

"react-dom.production.min.js:2857 Uncaught DOMException: Failed to execute 'btoa' on 'Window': The string to be encoded contains characters outside of the Latin1 range."

image

I searched from the internet,The reason seems to be this:

This error indicates that a string that does not conform to the Latin1 character set range was passed while using the btoa function. The Latin1 character set (also known as ISO-8859-1) contains most commonly used Latin letters and numbers, but excludes Chinese characters and some other common non-Latin characters.

To solve this problem, you need to transcode the strings so that they conform to the range of the Latin1 character set. This can be done using JavaScript's encodeURIComponent function, for example:

var str = "这是一个包含中文字符的字符串";
var encodedStr = encodeURIComponent(str);

// now you can use btoa safely
var base64Str = btoa(encodedStr);

could you please fix this problem?thank you very much!

Your website(https://www.jsv9000.app/) is very good!

lm101845 avatar Dec 15 '22 01:12 lm101845