You are not logged in.

#1 2017-03-30 09:03:22

rogorido
Member
Registered: 2009-08-17
Posts: 115

Sudden encoding change of a text file

I have a file text (Utf-8) in a ext4 partition which I have since years without problems. Today after the system upgrade I restarted awesome-wm and this file (and only this file) has lost its codification.

I get the following:
>>> file privat.org   
privat.org: data
>>> file -bi privat.org
application/octet-stream; charset=binary

And it should be: something like
>>> file projekte.org       
projekte.org: UTF-8 Unicode text, with very long lines

Vim and more show in the console the file with the usual normal spanish diacritics. But emacs shows only strange codes for them...

Any ideas?
1. as always converting a file with iconv, etc. it's a pain
2. emacs gives an error (some characters can not be encoded) if I try to save the file with utf8 encoding

Offline

#2 2017-03-30 18:39:21

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 78,493

Re: Sudden encoding change of a text file

Can you share eg. the first 100 bytes of the file?

od -N 100 -A x -t x1z -v privat.org

Maybe some application added a garbage BOM (the file should start with printable ASCII or "EF BB BF" - latter being the UTF-8 BOM.

Offline

#3 2017-04-03 07:24:29

rogorido
Member
Registered: 2009-08-17
Posts: 115

Re: Sudden encoding change of a text file

Thanks for your reply. Yes, of course. I get this:

000000 23 2b 53 54 41 52 54 55 50 3a 20 6f 76 65 72 76  >#+STARTUP: overv<
000010 69 65 77 20 68 69 64 65 73 74 61 72 73 0a 23 2b  >iew hidestars.#+<
000020 46 49 4c 45 54 41 47 53 3a 20 3a 70 65 72 73 6f  >FILETAGS: :perso<
000030 6e 61 6c 3a 0a 23 2b 43 41 54 45 47 4f 52 59 3a  >nal:.#+CATEGORY:<
000040 20 70 65 72 73 6f 6e 61 6c 0a 0a 2a 20 47 65 6e  > personal..* Gen<
000050 65 72 61 6c 0a 3a 50 52 4f 50 45 52 54 49 45 53  >eral.:PROPERTIES<
000060 3a 0a 3a 41                                      >:.:A<
000064

But I don't see any difference with other files which are being represented well in emacs...

Last edited by rogorido (2017-04-03 07:55:47)

Offline

#4 2017-04-03 22:39:54

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 78,493

Re: Sudden encoding change of a text file

The header is ok. There seems to be some stray byte in the file, but not in the beginning. Just try

iconv -t utf8 privat.org

It should print a utf8 version of the file and stop when reaching the (first) bad byte, printing the position so you can inspect where the issue is.

Offline

Board footer

Powered by FluxBB