Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I can't copy the code to the page #41

Open
lm101845 opened this issue Dec 15, 2022 · 2 comments
Open

I can't copy the code to the page #41

lm101845 opened this issue Dec 15, 2022 · 2 comments

Comments

@lm101845
Copy link

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
Copy link
Author

I cloned your code and run,I found that if I added this code I seemed could fix the problem:

image

image

the file location is js-visualizer-9000-client/src/components/ShareButton.js 84row

@cloudyan
Copy link

cloudyan commented Jun 8, 2023

I cloned your code and run,I found that if I added this code I seemed could fix the problem:

the file location is js-visualizer-9000-client/src/components/ShareButton.js 84row

url.searchParams.set('code', btoa(encodeURIComponent(code)));

It's working

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants