What are <84>, <82>?


 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers What are <84>, <82>?
# 1  
Old 09-22-2017
Linux What are <84>, <82>?

Hi,
I am editing a text file in VI and am occasionally seeing "characters" <82> and <84>. in my VIM they are marked in the same way the EOL character ^M is.
When running
:cat filename.txt
the characters seem to be read as a linefeed.
How do I search and replace these characters in VI.
What are they?
I do know that for the EOL character I press CTRL-V and "Enter" to get ^M.

Is there a list of these characters somewhere. <82> does not seem to be "T"
# 2  
Old 09-22-2017
The <hex_digits> (in blue if you're using a color terminal is the hexadecimal value of a byte that is not part of a valid character in your current locale.

You can translate the hex value(s) to octal using printf. And then you can use tr to delete those characters. For example, if vi shows you <82>, <84>, and <fe>; you could use:
Code:
printf '\\%03o\n' 0x82 0x84 0xfe

which would give you:
Code:
\202
\204
\376

and then you could use:
Code:
LC_ALL=C tr -d '\202\204\376' < input_file > output_file

to remove all occurrences of those three byte values from input_file with the updated contents stored in the file output_file.
# 3  
Old 09-22-2017
Quote:
Originally Posted by CaptSutter
Hi,
I am editing a text file in VI and am occasionally seeing "characters" <82> and <84>. in my VIM they are marked in the same way the EOL character ^M is.
When running
:cat filename.txt
the characters seem to be read as a linefeed.
How do I search and replace these characters in VI.
What are they?
I do know that for the EOL character I press CTRL-V and "Enter" to get ^M.
Is there a list of these characters somewhere. <82> does not seem to be "T"
Hello CaptSutter,

Welcome to forums, I hope you will enjoy learning and sharing knowledge here. Coming to your question. You could see control M characters by doing cat -v Input_file and if you want to remove control M characters from Input_file then use following command too on same(if your objective is to only remove control M characters).
Code:
tr -d '\r' < Input_file > temp_file && mv temp_file Input_file

Let me know if you have any queries on same.

Thanks,
R. Singh
# 4  
Old 09-22-2017
Depending on the locale, those chars should not come alone. In e.g. UTF-8 encoding, they'll be accompanied by a leading C2 (hex), which then should be removed as well.
Login or Register to Ask a Question

Previous Thread | Next Thread
Login or Register to Ask a Question