为什么文件编码类型为空?

发布于 2025-02-03 00:50:40 字数 567 浏览 2 评论 0原文

我的文件有问题,我从备份中下载了文件不支持的文本编码。我使用一个小python脚本检查编码类型:

import chardet
import glob

print('')
print("File".ljust(45), "Encoding")
for filename in glob.glob('./*.js'):
    with open(filename, 'rb') as rawdata:
        result = chardet.detect(rawdata.read())
    print(filename.ljust(45), result['encoding'])

这些是结果:

 文件编码
。\ index.js无
。\ test.js ascii
 

我创建了一个新的JS文件“ test.js”来检查脚本是否有效,是的,它正在工作,并且index.js文件“损坏”或“损坏”(编码)。

是否有可能“修复”包围类型并能够打开它?

I'm having a problem with my files, I downloaded a file from a backup I had but when I open it in VSCode I get an error on my screen: The file is not displayed in the editor because it is either binary or uses an unsupported text encoding. I check the encoding type with a small python script:

import chardet
import glob

print('')
print("File".ljust(45), "Encoding")
for filename in glob.glob('./*.js'):
    with open(filename, 'rb') as rawdata:
        result = chardet.detect(rawdata.read())
    print(filename.ljust(45), result['encoding'])

These are the results:

File                                          Encoding
.\index.js                                    None
.\test.js                                     ascii

I created a new JS file "test.js" to check that script works and... yep, it's working and the index.js file is "broken" or "corrupted" (the encoding).

Is there any possibility to "fix" the enconding type and be able to open it?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文