如何检测DOS换行符在一个文件? [英] How can I detect DOS line breaks in a file?

查看:189
本文介绍了如何检测DOS换行符在一个文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一堆文件。有些是Unix行结尾的,很多都是DOS。我想测试每个文件,以查看是否格式化的DOS,之前我切换行结束。

I have a bunch of files. Some are Unix line endings, many are DOS. I'd like to test each file to see if if is dos formatted, before I switch the line endings.

我会怎么做呢?是否有一个标志,我可以测试?类似的东西?

How would I do this? Is there a flag I can test for? Something similar?

推荐答案

您可以搜索字符串\\ r \\ n 。这是DOS风格的行结束。

You could search the string for \r\n. That's DOS style line ending.

编辑:看看

这篇关于如何检测DOS换行符在一个文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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