Text Editor which shows \r\n? [closed]

2020-01-27 02:37发布

I'm looking for a text editor that can show me the actual carriage returns and newlines.

E.g. if I save this string: "This\rIs\r\nA\nString"

Instead of showing

This
Is
A
String

I'm looking for some text editor which will show

This\rIs\r\nA\nString

I believe a problem with my text-file parsing in a certain program is being caused by inconsistent newline/carriage return/both on the ends of lines.

I could just make a program which can read a file and display it with that formatting, but I figured it'd be easier if anyone knew of one that can already do it.

Thanks!

[EDIT]
Forgot to specify I'm on Windows, and installing Cygwin isn't really an option. Otherwise I would use vi or vim.
Also, if there's a way to do this in PSPad, which is already installed, it would be awesome if you knew that too. Thanks!

17条回答
戒情不戒烟
2楼-- · 2020-01-27 02:48

Write a small program that does the trick. Depending on the language you use it takes between 10 seconds to 1 min. Faster than installing any application for sure. In command line with proper setup PHP

php -q

<?php $t=file_get_contents("filename"); echo str_replace(array("\n", "\r"), array("\\n", "\\r"), $t); ?>
查看更多
▲ chillily
3楼-- · 2020-01-27 02:49

Slickedit and Notepad2 also show them. In Slickedit you can customize all sorts of invisible characters (whitespace, tabs, CRs, line feeds, ...) and display them with any character you wish.

查看更多
孤傲高冷的网名
4楼-- · 2020-01-27 02:51

vi can show all characters.

查看更多
成全新的幸福
5楼-- · 2020-01-27 02:52

EmEditor does this. You can also customize what symbols actually display to show them.

查看更多
爷、活的狠高调
6楼-- · 2020-01-27 02:53

SciTE does that very well with a single keystroke. It is also able to detect the most probably current line ending of the file (in case of mixed lines) and to convert them.
No need to install, lightweight, it can be used as a tool even if you don't want to give up your favorite editor.

查看更多
再贱就再见
7楼-- · 2020-01-27 02:54

In vi(m), check out:

:help 'list'
:help 'listchars' 
查看更多
登录 后发表回答