I am unable to save a buffer due to a character encoding.
I am doing exploratory data analysis using Org babel. Data is read from a file using Python and the results are printed to the buffer.
#+begin_src python :session (concat "*Python: " (file-name-nondirectory (buffer-file-name)) "*") :results output :exports both :tangle yes dater = r"path\to\data.txt" with open(dater) as f: line1 = f.readline() line2 = f.readline() line3 = f.readline() print(line1) print(line2) print(line3) #+end_src #+RESULTS: : Freq. V(Vout_2,Vin) : : Step Information: Run=0 (Run: 1/513) : : 1.00000000000000e+00 (-4.48239687492628e+01dB,1.66628953595615e+02\260)
There is a
\260 character at the end of the last line which Emacs complains about:
These default coding systems were tried to encode text in the buffer ‘task.org’: (iso-latin-1-dos (5414 . 4194224)) However, each of them encountered characters it couldn’t encode: iso-latin-1-dos cannot encode these: \260
I can open the file directly in Emacs and the character renders (see the degree symbol?):
1.00000000000000e+00 (-4.48239687492628e+01dB,1.66628953595615e+02°) 1.04712854805090e+00 (-4.42065188662135e+01dB,1.65176722894121e+02°)
The file encoding that Emacs chooses for the raw file is:
1 -- iso-latin-1-dos (alias: iso-8859-1-dos latin-1-dos) ISO 2022 based 8-bit encoding for Latin-1 (MIME:ISO-8859-1). Type: charset (charset) EOL type: CRLF This coding system encodes the following charsets: iso-8859-1
However, regardless of what file encoding I put for the file local variable in the analysis file, Emacs complains when I try to save the analysis buffer.
#+COMMENT: -*- coding: iso-8859-1; -*-
iso-8859-15, etc. Basically going down the list of
list-coding-systems. I haven't tried all of them yet. But at this point I'm just guessing. To move forward, I'm manually deleting the offending character and saving as
utf-8. How can I find an encoding so that I don't need to manually delete results?