unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Miles Bader <miles.bader@necel.com>
To: emacs-devel@gnu.org
Subject: auto-recognizing utf-16le ?
Date: Mon, 15 Jun 2009 20:40:46 +0900	[thread overview]
Message-ID: <buo8wjtragx.fsf@dhlpc061.dev.necel.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1358 bytes --]

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


Thanks,

-Miles


[-- Attachment #2: test file encoded using utf-16le --]
[-- Type: application/octet-stream, Size: 30 bytes --]

[-- Attachment #3: Type: text/plain, Size: 167 bytes --]



-- 
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
service.

             reply	other threads:[~2009-06-15 11:40 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-15 11:40 Miles Bader [this message]
2009-06-15 21:45 ` auto-recognizing utf-16le ? Andreas Schwab
2009-06-16  0:20   ` Miles Bader
2009-06-16  2:04   ` Kenichi Handa
2009-06-16 15:01     ` Andreas Schwab
2009-06-17  0:43       ` Kenichi Handa

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=buo8wjtragx.fsf@dhlpc061.dev.necel.com \
    --to=miles.bader@necel.com \
    --cc=emacs-devel@gnu.org \
    --cc=miles@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).