Text files on linux have "<97>" characters

5

When viewing a particular text file in vim or less on Linux or OS X, all the en dashes show up as highlighted "<97>" characters.

What control-sequence do I need to type in order to substitute the hyphens back? For example, the following doesn't work in vim:

% s/<97>/--/g 

Typing bracket nine seven bracket is not the same as typing the actual special character.

Joel Eidsath

Posted 2010-04-28T23:11:48.343

Reputation: 113

Answers

2

The correct fix is to take your file and run it through iconv to convert from CP1252 to UTF-8.

Ignacio Vazquez-Abrams

Posted 2010-04-28T23:11:48.343

Reputation: 100 516

6

After some troubleshooting I seem to have figured it out. The control sequence is

ctrl-V X 9 7 

Substituting that for the <97> in the vim code above works.

Joel Eidsath

Posted 2010-04-28T23:11:48.343

Reputation: 113

@marcusw: A question must be at least two days old before the OP can accept their own answer. http://meta.stackexchange.com/questions/6044/why-must-i-wait-2-days-before-accepting-my-own-answer

– Chris Johnsen – 2010-04-29T01:13:11.187

1

You can also tell vim to re-interpret the text file using a different codepage. In command mode, enter

:e ++enc=cp1252

That should fix your em-dashes and any other unusual characters in your source text.

Andrew Paul Landells

Posted 2010-04-28T23:11:48.343

Reputation: 11