-1

I have a large text file that I take notes in; Recently, after saving it, it won't open and gives following error. I tried a few things on web that didn't work---opening in different encoding format, etc. Nothing worked. Any idea how I can open it again? Is there a language I can use from bash? I'm very familiar with PHP. Any ideas? Different text editor?

Error:

"The document “ToDo.txt” could not be opened. Text encoding Unicode (UTF-8) isn’t applicable."

"The file may have been saved using a different text encoding, or it may not be a text file."

Manuel Mannhardt
  • 2,191
  • 1
  • 17
  • 23
user1446797
  • 129
  • 2
  • 9
  • Yes, different text editor. Else `recode` for checking/conversion. Or PHP or an hexeditor read it raw and inspect. -- This is too little details for an SO question / and barely seems a programming question as of now. – mario Nov 14 '17 at 18:10
  • What happens when you try to open it via notepad for example? Which editor you get this error? Also this is not related to programming nor PHP or bash – Manuel Mannhardt Nov 14 '17 at 18:10
  • Probable Duplicate of [UTF-8 all the way through](https://stackoverflow.com/questions/279170/utf-8-all-the-way-through) – mario Nov 14 '17 at 18:11
  • I get this error in TextEdit on Mac @ManuelMannhardt – user1446797 Nov 14 '17 at 18:11
  • Does this file contain sensitive informations? If not, please upload it somewhere and provide a link. Otherwise I dont think we can help you since we cant see what happens. If yes, can you try to reproduce what happended in a sample file? – Manuel Mannhardt Nov 14 '17 at 18:13
  • @ManuelMannhardt It does have some email-info, so I rather not share it I think. Do you think notepad would help? Something else? – user1446797 Nov 14 '17 at 18:15
  • Ok then dont upload it and try to create another "corrupted" text file which we can take a look at (just do the same as you do to the real file) – Manuel Mannhardt Nov 14 '17 at 18:17
  • @mario the hyperlink seems useful, though rly I just want to open this as a document on my Mac. I was thinking as last resort to try to use bash or some other way of reading and writing it. – user1446797 Nov 14 '17 at 18:18
  • @ManuelMannhardt It's not clear to me how to reproduce error. I think it may have to do with size; not sure. – user1446797 Nov 14 '17 at 18:21
  • @ManuelMannhardt Do you think other editors are worth trying or reading in command line via simple scripts? – user1446797 Nov 14 '17 at 18:42
  • Its very hard to tell, but yes I would definetly try out other editors (Sublime, Atom, Notepad++, etc.). One more thing, does your file contain "strange" symbols? Like chinese characters or something? – Manuel Mannhardt Nov 14 '17 at 18:44
  • @ManuelMannhardt I don't think so, but maybe that's what caused it? This is a text file that I add notes to almost daily. I was wondering if it was the size or a character I entered that caused this problem. – user1446797 Nov 14 '17 at 18:46
  • @ManuelMannhardt Should I try reading in via terminal/bash at all? Line by line for example? – user1446797 Nov 14 '17 at 18:49
  • Size shouldnt be an issue. At least not if you dont store gigabytes of data lol. You can test this, if you create a new textfile with a size bigger/equal to the one corrupted. I was just wondering about the chars, because I had a problem with encodings yesterday too and there was a PHP library which fixed my encoding. Maybe you can try opening the file with PHP and using the utf8 fix on it? Library is found at: https://github.com/neitanod/forceutf8 – Manuel Mannhardt Nov 14 '17 at 18:49
  • @ManuelMannhardt let me look into and follow up later today. – user1446797 Nov 14 '17 at 18:56

1 Answers1

0

cat the file from the CLI and make sure your data is still there. Then you could simply copy and paste the output into a new file and hopefully get rid of whatever weird encodings are causing that text editor to not read the file.

Robert
  • 1
  • 1
  • 2