这不是一个真正的编程问题,是否有命令行或Windows工具(Windows 7)来获取文本文件的当前编码?当然,我可以写一个小c#应用程序,但我想知道是否有一些已经内置?
当前回答
您可以在文件位置上打开git bash,然后运行命令file -i file_name来检查
例子
user filesData
$ file -i data.csv
data.csv: text/csv; charset=utf-8
其他回答
如果你的Windows机器上有“git”或“Cygwin”,然后转到文件所在的文件夹并执行命令:
file *
这将为您提供该文件夹中所有文件的编码细节。
EncodingChecker
文件编码检查器是一个GUI工具,允许您验证一个或多个文件的文本编码。该工具可以显示所有选定文件的编码,或者仅显示不具有指定编码的文件的编码。
文件编码检查程序需要。net 4或更高版本才能运行。
(Linux)命令行工具'file'可通过GnuWin32在Windows上使用:
http://gnuwin32.sourceforge.net/packages/file.htm
如果你安装了git,它位于C:\Program Files\git\usr\bin.
例子:
C:\Users\SH\Downloads\SquareRoot>file * _UpgradeReport_Files; directory Debug; directory duration.h; ASCII C++ program text, with CRLF line terminators ipch; directory main.cpp; ASCII C program text, with CRLF line terminators Precision.txt; ASCII text, with CRLF line terminators Release; directory Speed.txt; ASCII text, with CRLF line terminators SquareRoot.sdf; data SquareRoot.sln; UTF-8 Unicode (with BOM) text, with CRLF line terminators SquareRoot.sln.docstates.suo; PCX ver. 2.5 image data SquareRoot.suo; CDF V2 Document, corrupt: Cannot read summary info SquareRoot.vcproj; XML document text SquareRoot.vcxproj; XML document text SquareRoot.vcxproj.filters; XML document text SquareRoot.vcxproj.user; XML document text squarerootmethods.h; ASCII C program text, with CRLF line terminators UpgradeLog.XML; XML document text C:\Users\SH\Downloads\SquareRoot>file --mime-encoding * _UpgradeReport_Files; binary Debug; binary duration.h; us-ascii ipch; binary main.cpp; us-ascii Precision.txt; us-ascii Release; binary Speed.txt; us-ascii SquareRoot.sdf; binary SquareRoot.sln; utf-8 SquareRoot.sln.docstates.suo; binary SquareRoot.suo; CDF V2 Document, corrupt: Cannot read summary infobinary SquareRoot.vcproj; us-ascii SquareRoot.vcxproj; utf-8 SquareRoot.vcxproj.filters; utf-8 SquareRoot.vcxproj.user; utf-8 squarerootmethods.h; us-ascii UpgradeLog.XML; us-ascii
一个简单的解决方案可能是在Firefox中打开该文件。
将文件拖放到firefox中 按Ctrl+I打开页面信息
和文本编码将出现在“页面信息”窗口。
注意:如果文件不是txt格式,请将其重命名为txt,然后重试。
附:欲了解更多信息,请参阅这篇文章。
您可以在文件位置上打开git bash,然后运行命令file -i file_name来检查
例子
user filesData
$ file -i data.csv
data.csv: text/csv; charset=utf-8
推荐文章
- Windows下的端口转发
- Windows版本的cron是什么?
- cmd.exe使用的编码/代码页是什么?
- 如何从Windows资源管理器启动PowerShell ?
- 获取Windows中文件的编码
- 如何用批处理脚本对目录中的每个文件做一些事情
- 如何在Windows命令行中使用不同的颜色进行回显
- 如何检查进程是否通过批处理脚本运行
- 在windows的命令行上创建一个空文件(如linux的touch命令)
- DLL文件究竟是什么,它们是如何工作的?
- ArrayBuffer到base64编码的字符串
- 如何检查字符串是否为unicode或ascii?
- 键盘快捷键将剪贴板内容粘贴到命令提示符窗口(winxp)
- 如何检测文本文件的编码/编码页?
- 通过批处理或cmd文件停止和启动服务?