Wednesday, May 1, 2024
 Popular · Latest · Hot · Upcoming
0
rated 0 times [  0] [ 0]  / answers: 1 / hits: 1046  / 2 Years ago, fri, october 28, 2022, 1:06:20

Problem


Gedit says that one of my files using UTF-8 encoding has invalid characters, and may get corrupted if I continue to use it.


Details


The file in questions is my Someday/Maybe List. I usually add to it links to sources I'd like to read, such as blog posts. I suspect that the link of one of the sources I added contained invalid characters, causing my issue.


I found here that I need to run isutf8, then use xxd or hexdump to scan a file for invalid characters. Running isutf8 is pointless because if this page is correct, all it does is tell you whether a file has invalid characters or not. I've read some manpages on xxd, and other sources on hexdump, but I don't understand any of it.


What I've tried


Not much. I fear I might break the file or something if I edit it, so I left it untouched. Besides, my research skills are poor, so I couldn't find a solution to this myself.


More From » gedit

 Answers
7

This could in principle not happen if you exclusively use Gedit to edit the file. Characters in that case would be automatically converted to the character code of the current text file.


If for one reason incorrectly encoded characters would be introduced, then one way to find out where they are would be to use


grep -axv '.*' file.txt

(credit goes here). That command will only show lines containing invalid characters. To facilitate identification of the line, you can add the -n option to display the line number.


Then open the file in Gedit, continuing past the warning message that is given. You then can edit out the wrong characters. Save and close, then reopen the file. If no warning is issued anymore, all wrong characters have been removed.


[#1741] Saturday, October 29, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
kneducator

Total Points: 226
Total Questions: 111
Total Answers: 108

Location: Mexico
Member since Sun, Jul 25, 2021
3 Years ago
kneducator questions
Tue, Dec 6, 22, 09:22, 1 Year ago
Sun, Apr 30, 23, 23:26, 1 Year ago
Tue, Jun 8, 21, 01:25, 3 Years ago
Sun, Mar 12, 23, 10:51, 1 Year ago
Tue, Dec 7, 21, 03:59, 2 Years ago
;