如何确定Windows / IIS上的文件编码? [英] How can I determine file encodings on Windows / IIS?

查看:158
本文介绍了如何确定Windows / IIS上的文件编码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此问题我们的服务器上有一个文件存在编码错误。



我以前看过这种情况,最常见的是从Word中粘贴到Visual Studio,当保存文件时,智能引号可能会干扰Visual Studio的编码设置。



事情是 - 我遇到的问题涉及到20-30个不同的脚本文件,包括文件等(嘿,这是我们当天如何保持模块化)...我真的不想在Visual Studio中打开它们,并单独检查文件编码。 p>

有没有什么办法可以分析一个文件夹中的文件,并分别列出每个文件名以及用于保存文件的文本编码? (或者 - 如果编码没有被明确指定 - 确定用于保存文件的Microsoft IIS 认为的编码)。

解决方案

文本文件的编码就是如何被解释的,所以你无法以可靠的方式检测到这个。您可以检测到UTF-8和16位unicode,但ISO-8859-1 / 2/3/4等(Windows-1250/1251/1252等)无法区分。



如果您的文档包含奇怪的引号,除或之外,您可以简单地找到这些引号,并手动替换。


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?)

解决方案

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.

这篇关于如何确定Windows / IIS上的文件编码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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