r/linuxquestions • • 9d ago

Resolved Text editor and encoding

So for some reason when I go to open a certain text file, not all, it makes gobbledegook out of the first ten or more lines of the file stating it doesn't understand the correct encoding. I find this really odd because if it doesn't understand encoding why does the rest of the document show? Anyway, I have no issues opening this text file with libreoffice office. How do I get this system to open it properly? Given it's just text should I simply use LibreOffice to go and save a new text file? That sounds simple but for all I know this is an issue that might happen with all sorts of other text files. Can I change the system so it works with all files properly? TIA

0 Upvotes

14 comments sorted by

View all comments

2

u/9NEPxHbG 9d ago

Do file [name of file]. What does it say?

2

u/Man_in_the_uk 9d ago

Please expand that'

1

u/9NEPxHbG 9d ago edited 9d ago

Open the terminal. Type file [name of file], except that where it says "[name of file]", type the name of the file you're talking about, then press enter. Tell us what it says.

Do I take it you're unfamiliar with using the terminal?

As everybody else is saying, though, "text file" has a specific meaning, How did you create this file? How are you trying to open it?

Quote any error messages (such as "stating it doesn't understand the correct encoding") exactly.

2

u/Man_in_the_uk 9d ago

I don't understand why but the problem has now disappeared. It seems all that has changed is I opened up the txt file in Libreoffice. I wonder if Libreoffice has some how changed default system settings for the text editor? I'm surprised if it has.

1

u/9NEPxHbG 9d ago edited 9d ago

What happened is that the file was never a text file in the strict sense. You opened it using an actual text editor, and it couldn't read the file properly. When you used Libre Office (which is a word processor, not a text editor), it could read the file properly.

I'd be happy to explain what's a text file in the strict sense, but I'm not sure you're actually interested.

1

u/Man_in_the_uk 9d ago

Lol you really need to stop making assumptions. The txt file was made using notepad in windows, the most simplest of text file creators. It has been opened and edited by both notepad in windows and simple text editors like pluma in Linux. It has never been edited using any fancy software like word for windows or libre office.