unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* change input coding
@ 2005-04-11  6:32 Uwe Mayer
  2005-04-11  9:05 ` Peter Dyballa
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Uwe Mayer @ 2005-04-11  6:32 UTC (permalink / raw)


Hi,

I have an xml file in utf-16-be format which I want to edit in emacs.
Unfortunately it does not start with a 

<!-- -*- coding: utf-16-be -*- -->

so that emacs would decode and display it properly (which I'd hope).
Currently it looks somewhat like:

^@<^@l^@o^@g^@E^@n ...
for
<logEn ...

I know that it is utf-16-be as I can decode it with Python. How can I load a
utf-16-be file in emacs such that it is displayed propperly?
The set-buffer-file-coding-system only changes the current coding which
doesn't get rid of the ^@ (which are actually 0x00 characters).

Thanks,
Ciao
Uwe     

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: change input coding
  2005-04-11  6:32 change input coding Uwe Mayer
@ 2005-04-11  9:05 ` Peter Dyballa
  2005-04-11 11:37 ` Reiner Steib
       [not found] ` <mailman.1037.1113208992.2895.help-gnu-emacs@gnu.org>
  2 siblings, 0 replies; 7+ messages in thread
From: Peter Dyballa @ 2005-04-11  9:05 UTC (permalink / raw)
  Cc: help-gnu-emacs


Am 11.04.2005 um 08:32 schrieb Uwe Mayer:

> I know that it is utf-16-be as I can decode it with Python. How can I 
> load a
> utf-16-be file in emacs such that it is displayed propperly?
>

There are (at least) two ways:

1. Create an empty file (b) containing only

	<!-- -*- mode: Text; coding: utf-16-be; -*- -->

   and cat the original file (a) into that (cat a >> b).

2. Temporarily set:

	   (setq default-buffer-file-coding-system 'utf-16-be)
	   (set-default-coding-systems			 'utf-16-be)
	   (prefer-coding-system				 'utf-16-be)

    (Copy into *scratch* buffer, mark region, eval-region.)

--
Mit friedvollen Grüßen

   Pete

“Computers are good at following instructions, but not at reading your 
mind.”
    - D. E. Knuth, The TeXbook, Addison-Wesley 1984, 1986, 1996, p. 9

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: change input coding
  2005-04-11  6:32 change input coding Uwe Mayer
  2005-04-11  9:05 ` Peter Dyballa
@ 2005-04-11 11:37 ` Reiner Steib
       [not found] ` <mailman.1037.1113208992.2895.help-gnu-emacs@gnu.org>
  2 siblings, 0 replies; 7+ messages in thread
From: Reiner Steib @ 2005-04-11 11:37 UTC (permalink / raw)


On Mon, Apr 11 2005, Uwe Mayer <merkosh@hadiko.de> wrote:

> How can I load a utf-16-be file in emacs such that it is displayed
> propperly?  The set-buffer-file-coding-system only changes the
> current coding which doesn't get rid of the ^@ (which are actually
> 0x00 characters).

[ C&P from <news:v9d5u7we9g.fsf@marauder.physik.uni-ulm.de> ... ]

`C-x RET c NEWCODING-SYSTEM RET C-x C-v RET'

Emacs 22 will have a more simple command for this task:

,----[ `C-h k C-x RET r' ]
| C-x RET r runs the command revert-buffer-with-coding-system
|    which is an interactive compiled Lisp function in `international/mule'.
| It is bound to C-x RET r, <menu-bar> <options> <mule>
| <set-various-coding-system> <revert-buffer-with-coding-system>.
| (revert-buffer-with-coding-system CODING-SYSTEM &optional FORCE)
| 
| Visit the current buffer's file again using coding system CODING-SYSTEM.
| For a list of possible values of CODING-SYSTEM, use M-x list-coding-systems.
`----

[ ... end of C&P ]

`file-coding-system-alist' might also be an option.


Bye, Reiner.
-- 
       ,,,
      (o o)
---ooO-(_)-Ooo---  |  PGP key available  |  http://rsteib.home.pages.de/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: change input coding
       [not found] ` <mailman.1037.1113208992.2895.help-gnu-emacs@gnu.org>
@ 2005-04-11 12:34   ` Sébastien Kirche
  2005-04-11 13:06     ` Peter Dyballa
       [not found]     ` <mailman.1059.1113223178.2895.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 7+ messages in thread
From: Sébastien Kirche @ 2005-04-11 12:34 UTC (permalink / raw)


Le 11 Apr 2005, Peter Dyballa a dit :

> There are (at least) two ways:
> 
> 1. Create an empty file (b) containing only
> 
> 	<!-- -*- mode: Text; coding: utf-16-be; -*- -->
> 
> and cat the original file (a) into that (cat a >> b).
> 
> 2. Temporarily set:
> 
> 	   (setq default-buffer-file-coding-system 'utf-16-be)
> 	   (set-default-coding-systems			 'utf-16-be)
> 	   (prefer-coding-system				 'utf-16-be)
> 
> (Copy into *scratch* buffer, mark region, eval-region.)

What about changing the coding system just before opening the file ?
C-x RET c utf-16-be RET C-x C-f <the file>

It would  change the coding  system locally to  the opened file  rather than
changing it globally for the emacs session.

Then the  OP could just add  the first line as  you described in  1) for the
next time he will open it.

-- 
Sébastien Kirche

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: change input coding
  2005-04-11 12:34   ` Sébastien Kirche
@ 2005-04-11 13:06     ` Peter Dyballa
  2005-04-11 20:07       ` Eli Zaretskii
       [not found]     ` <mailman.1059.1113223178.2895.help-gnu-emacs@gnu.org>
  1 sibling, 1 reply; 7+ messages in thread
From: Peter Dyballa @ 2005-04-11 13:06 UTC (permalink / raw)
  Cc: help-gnu-emacs


Am 11.04.2005 um 14:34 schrieb Sébastien Kirche:

> What about changing the coding system just before opening the file ?
> C-x RET c utf-16-be RET C-x C-f <the file>
>

Does it really work? I tried it myself a few times and did not get the 
result I wished -- but I should do better testing for that and then 
complain in the right list!

I often launch for some testing another GNU Emacs, so it doesn't make 
such a big difference when changing things globally ...

--
Greetings

   Pete

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: change input coding
       [not found]     ` <mailman.1059.1113223178.2895.help-gnu-emacs@gnu.org>
@ 2005-04-11 13:48       ` Sébastien Kirche
  0 siblings, 0 replies; 7+ messages in thread
From: Sébastien Kirche @ 2005-04-11 13:48 UTC (permalink / raw)


Le 11 Apr 2005, Peter Dyballa s'est exprimé ainsi :

> 
> Am 11.04.2005 um 14:34 schrieb Sébastien Kirche:
> 
> > What about changing the coding system just before opening the file ?
> > C-x RET c utf-16-be RET C-x C-f <the file>
> > 
> 
> Does it really work? I tried it myself a few times and did not get the 
> result I wished -- but I should do better testing for that and then 
> complain in the right list!

At least it works great in OSX while opening some mac-roman encoded file with
french accentuated characters whilst my prefer-coding-system within Emacs is
latin-9.

BTW : it works also with copy/paste between Emacs and other Mac applications.

> I often launch for some testing another GNU Emacs, so it doesn't make 
> such a big difference when changing things globally ...

C-x RET  c lets  you use another  coding system  for just a  single command.
After your environment remains unchanged (except for opening/saving a file :
it defines the buffer coding system).

-- 
Sébastien Kirche

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: change input coding
  2005-04-11 13:06     ` Peter Dyballa
@ 2005-04-11 20:07       ` Eli Zaretskii
  0 siblings, 0 replies; 7+ messages in thread
From: Eli Zaretskii @ 2005-04-11 20:07 UTC (permalink / raw)


> From: Peter Dyballa <Peter_Dyballa@Web.DE>
> Date: Mon, 11 Apr 2005 15:06:31 +0200
> Cc: help-gnu-emacs@gnu.org
> 
> > What about changing the coding system just before opening the file ?
> > C-x RET c utf-16-be RET C-x C-f <the file>
> 
> Does it really work?

It should.  If it doesn't, please report that as a bug.

> I tried it myself a few times and did not get the result I wished

FWIW, it works for me every time.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2005-04-11 20:07 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-04-11  6:32 change input coding Uwe Mayer
2005-04-11  9:05 ` Peter Dyballa
2005-04-11 11:37 ` Reiner Steib
     [not found] ` <mailman.1037.1113208992.2895.help-gnu-emacs@gnu.org>
2005-04-11 12:34   ` Sébastien Kirche
2005-04-11 13:06     ` Peter Dyballa
2005-04-11 20:07       ` Eli Zaretskii
     [not found]     ` <mailman.1059.1113223178.2895.help-gnu-emacs@gnu.org>
2005-04-11 13:48       ` Sébastien Kirche

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