如何确定 Windows/IIS 上的文件编码?
从这个问题的答案我们的服务器上似乎有一个文件以错误的编码保存。
我以前见过这种情况 - 最常见的是从 Word 粘贴到 Visual Studio 时,“智能引号”可能会在保存文件时干扰 Visual Studio 的编码设置。
问题是 - 我遇到的问题涉及 20-30 个不同的脚本文件、包含文件等等(嘿,这就是我们当年保持模块化的方式......),我真的不想打开每个在 Visual Studio 中打开其中之一并单独检查文件编码。
有什么方法可以分析充满文件的文件夹树并吐出每个文件名的列表以及用于保存文件的文本编码? (或者 - 如果没有明确指定编码 - 找出 Microsoft IIS 认为 用于保存文件的编码?)
From the answers to this question it appears there's a file somewhere on our server that's been saved with the wrong encoding.
I've seen this happen before - most often when pasting from Word into Visual Studio, when "smart quotes" can interfere with Visual Studio's encoding settings when saving the file.
Thing is - the problem I'm having involves 20-30 different script files, include files and so on (hey, that was how we kept it modular back in the day...) and I really don't want to open every one of them in Visual Studio and check the file encodings individually.
Is there any way I can analyze a folder tree full of files and spit out a list of each filename along with the text encoding used to save the file? (Or - if encodings aren't clearly specified - work out what encoding Microsoft IIS thinks was used to save the file?)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
文本文件的编码正是其预期的解释方式,因此您无法以可靠的方式检测到这一点。您可能可以检测 UTF-8 和 16 位 unicode,但无法区分 ISO-8859-1/2/3/4 等...(Windows-1250/1251/1252 等)。
如果您的文档包含除“”或“”之外的“奇怪”引号,您只需找到这些引号,然后手动替换它们即可。
A textfile's encoding is just how it was intended to be interpreted, so you cannot detect this in a reliable way. You can probably detect UTF-8 and 16-bit unicode, but there's no way distinguishing between ISO-8859-1/2/3/4 etc... (Windows-1250/1251/1252 etc.).
If your document contains "weird" quotes, other than "" or '', you can simply find these, and replace them manually.