[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

auto-recognizing utf-16le ?

From: Miles Bader
Subject: auto-recognizing utf-16le ?
Date: Mon, 15 Jun 2009 20:40:46 +0900

Someone on #emacs noticed that emacs doesn't seem to auto-recognize
files encoding using utf-16le.  Visiting a file which uses such an
encoding results in the buffer having coding-system "no-conversion
(alias: binary)", and lots of ^@ (NUL) characters in the buffer.

Forcing the encoding with "C-x C-m r utf-16le RET" results in the
correct thing happening.

[He was on windows where this coding system is common, so it's kind of
annoying for him.]

I noticed that the same happens on debian.

I thought maybe he could just do:

   (prefer-coding-system 'utf-16le-dos)

but it seems to have no effect.

To reproduce:

   1. Save this message's attachment to a file "/tmp/oink"

   2. Start emacs with:  HOME=/tmp emacs -Q

   3. Visit the file you saved:  C-x C-f /tmp/oink RET

   4. ** Notice that the buffer contains ^@ (NUL) characters, and that
      the buffer coding-system is "no-conversion (binary)"

   5. Re-visit the file, forcing the coding-system:

         C-x C-m r utf-16le RET yes RET

   6. ** Notice that the file contents are now correct

   7. Kill the current buffer:  C-x k RET

   8. Evaluate:  M-: (prefer-coding-system 'utf-16le) RET

   9. Visit the file again:  C-x C-f /tmp/oink RET

  10. ** Notice that prefer-coding-system didn't seem to have any effect



Attachment: oink
Description: test file encoded using utf-16le

Justice, n. A commodity which in a more or less adulterated condition the
State sells to the citizen as a reward for his allegiance, taxes and personal

reply via email to

[Prev in Thread] Current Thread [Next in Thread]