Notepad++ 能识别编码吗? [英] Notepad++ can recognize encoding?

查看:33
本文介绍了Notepad++ 能识别编码吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 UTF-8 编码内容创建了文件(使用 PHP fputcsv).

I created file with UTF-8 encoded content (using PHP fputcsv).

当我在 Notepad++ 中打开此文件时 - 字符错误(Notepad++ 以 ANSI 编码开头).

When I open this file in Notepad++ - characters are wrong (Notepad++ starts with ANSI encoding).

当我从菜单中设置格式->以 UTF-8 编码"时 - 一切都很好.

When I set Format->"Encode in UTF-8" from menu - everything is fine.

我很担心,Notepad++ 可以以某种方式识别编码,也许我用 fputcsv 创建的文件有问题?第一个字节什么的?

Im worrying, that Notepad++ can recognize encoding somehow, and maybe something is wrong with my file created with fputcsv? First byte or something?

推荐答案

自动检测编码不是可以准确完成的.明确指定编码非常重要.在某些情况下可以猜测,但即使如此也不能100%确定.

Automatically detecting an encoding is not something that can be done accurately. It's pretty much essential that the encoding be specified explicitly. It can be guessed in some cases, but even then not with 100% certainty.

本文档(编码) 解释了与 Notepad++ 相关的情况.他们还指出,如果文件没有使用字节顺序标记 (BOM) 保存,就会出现困难.

This documentation (Encoding) explains the situation in relation to Notepad++. They also point out that the difficulty arises especially if the file has not been saved with a Byte Order Mark (BOM).

鉴于您手动设置编码后文件显示正确,我想说您生成和保存文件的方式没有任何问题.您唯一可以检查的是是否正在保存 BOM,这可能会提高 Notepad++ 能够自动检测编码的机会.

Given that your file displays correctly once you manually set the encoding, I would say there's nothing wrong with how you are generating and saving the file. The only thing you can check for is whether a BOM is being saved, which might improve the chances of Notepad++ being able to automatically detect the encoding.

值得注意的是,虽然它可以帮助 Notepad++ 等编辑器更准确地识别编码,但根据 The Unicode Standard 文档,不推荐使用 BOM.

It's worth noting that although it may help editors like Notepad++ identify the encoding more accurately, according to The Unicode Standard document, the BOM is not recommended.

这篇关于Notepad++ 能识别编码吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆