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

fix: 修复导出时字符乱码问题 #3972

Merged
merged 2 commits into from
Mar 7, 2024

Conversation

greenjerry
Copy link
Contributor

修复导出json和markdown时中文及其他utf8字符乱码问题

乱码原因:
charCodeAt方法返回值范围在0~65535,不能直接转为uint8array

修复方式:
把downloadAs方法中的writeBinaryFile改为writeTextFile,参考文档

Copy link

vercel bot commented Feb 2, 2024

@greenjerry is attempting to deploy a commit to the NextChat Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Contributor

github-actions bot commented Feb 2, 2024

Your build has completed!

Preview deployment

@H0llyW00dzZ
Copy link
Contributor

no
thats wrong

@H0llyW00dzZ
Copy link
Contributor

downloadAs literally must be use binary

@greenjerry
Copy link
Contributor Author

downloadAs literally must be use binary

Can you tell me why? I can pass the test on windows, macos, and web, including downloading json and markdown. The text field of the downloadAs method specifies that string is required, why cannot it be saved using writeTextFile?

@H0llyW00dzZ
Copy link
Contributor

downloadAs literally must be use binary

Can you tell me why? I can pass the test on windows, macos, and web, including downloading json and markdown. The text field of the downloadAs method specifies that string is required, why cannot it be saved using writeTextFile?

if you replace writeBinaryFile it wouldn't work for another such as image

@H0llyW00dzZ
Copy link
Contributor

its backend unlike frontend

@H0llyW00dzZ
Copy link
Contributor

also writeText it used to be copying a text, unlike writeBinaryFile

@greenjerry
Copy link
Contributor Author

No, I didn't replace writeBinaryFile from the global perspective. The download image section is not in the downloadAs method, it is in line 491 of exporter. tsx. Therefore, I only replace the writeBinaryFile in the downloadAs method and it does not affect the image

Furthermore, I did not remove writeBinaryFile from global. d.ts, so writeBinaryFile is still available in the project

@Dean-YZG
Copy link
Contributor

Dean-YZG commented Mar 7, 2024

Without replacing writeBinaryFile, you can use ArrayBuffer as a bridge object, use Uint16Array to write data to ArrayBuffer, and use Uint8Array to wrap ArrayBuffer and pass it to writeBinaryFile

@fred-bf fred-bf merged commit ff9f0e6 into ChatGPTNextWeb:main Mar 7, 2024
1 of 2 checks passed
@H0llyW00dzZ
Copy link
Contributor

H0llyW00dzZ commented Mar 7, 2024

Without replacing writeBinaryFile, you can use ArrayBuffer as a bridge object, use Uint16Array to write data to ArrayBuffer, and use Uint8Array to wrap ArrayBuffer and pass it to writeBinaryFile

you smart, that safe & better way

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

Successfully merging this pull request may close these issues.

4 participants