4

I have a bunch of html files encoded as iso-8859-1-unix and a few encoded in utf-8-unix. What I want is to encode all of them in utf-8-unix. I have already tried (I think they are the same command, actually):

C-x C-m f utf-8-unix
C-x RET f utf-8-unix

the modeline changes from 1 to U, but after I close the file and reopen it, the modeline shows 1 again. It seems that I cannot make the change permanent no matter what I try and I don't understand why.

Following the suggestions below, I have created a new file with this content

<ul class="navbar">
  <li><a href="index.php">home</a></li>
  <li><a href="bio.php">bio</a></li>
  <li><a href="research.php">research</a></li>
  <li><a href="software.php">software</a></li>
  <li><a href="contacts.php">contacts</a></li>
</ul>

C-h v buffer-file-coding-system returns this:

Its value is utf-8-unix
Local in buffer new.htm; global value is the same.

so it looks okay. I save, kill the buffer, reopen the file and C-h v buffer-file-coding-system returns this:

Its value is undecided-unix
Local in buffer new.htm; global value is utf-8-unix

I am really confused.

EDIT: thanks everybody for helping making this clear!

11
  • Are you saving the file after changing the encoding? Feb 25 '16 at 17:03
  • @JordonBiondo yes I am.
    – rs028
    Feb 25 '16 at 17:07
  • 1
    C-h v coding RET you must issue this command in that buffer. Maybe there is a special character forcing Emacs think the file has in a particular coding. Or maybe you have something in your init file.
    – giordano
    Feb 25 '16 at 17:49
  • 1
    Sorry, my fault, see buffer-file-coding-system variable
    – giordano
    Feb 25 '16 at 18:27
  • 4
    The example you gave in the question contains only ASCII characters. So its UTF-8 encoding and Latin-1 encoding will be identical. In particular, there is no way for emacs to tell the encodings apart when you open the file. Anyhow, if the <head> section of your HTML file contains <meta charset='utf-8'>, then html-mode should use that to decide the encoding when you open the file. No need to use file local variables in this case. Feb 25 '16 at 19:31
0

N.B.: Question answered in comments.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.