unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* How to get emacs to save files as UTF8
@ 2006-07-28 18:21 eric.goforth
  2006-07-28 20:31 ` Harald Hanche-Olsen
  2006-07-29 16:06 ` Ismael Valladolid Torres
  0 siblings, 2 replies; 3+ messages in thread
From: eric.goforth @ 2006-07-28 18:21 UTC (permalink / raw)


Hello,

I've changed the following in my .emacs file:

(custom-set-variables
  ;; custom-set-variables was added by Custom -- don't edit or
cut/paste it!
  ;; Your init file should contain only one such instance.
 '(case-fold-search t)
 '(current-language-environment "UTF-8")
 '(default-input-method "rfc1345")
 '(global-font-lock-mode t nil (font-lock)))
(custom-set-faces
  ;; custom-set-faces was added by Custom -- don't edit or cut/paste
it!
  ;; Your init file should contain only one such instance.
 )

However, I'm opening all of the .asp files in a directory using dired,
doing a search and replace for 65001, replacing it with 65001.

The first line of all my .asp files is:
 <%@ Language=VBScript CodePage=65001 %>

I then save all the files, but when I open one with notepad and do a
save as, ANSI is the default Encoding, leading me to think that they
aren't being saved as UTF8.

I'm using NTEmacs 21.3.1.  Alternatively, if someone knows of a quick
way to change the Encoding of a bunch of files to UTF8 in Windows XP,
I'm all ears.

-Eric

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

* Re: How to get emacs to save files as UTF8
  2006-07-28 18:21 How to get emacs to save files as UTF8 eric.goforth
@ 2006-07-28 20:31 ` Harald Hanche-Olsen
  2006-07-29 16:06 ` Ismael Valladolid Torres
  1 sibling, 0 replies; 3+ messages in thread
From: Harald Hanche-Olsen @ 2006-07-28 20:31 UTC (permalink / raw)


+ eric.goforth@gmail.com:

| I've changed the following in my .emacs file:
|
| (custom-set-variables
|   [snip]
|  '(current-language-environment "UTF-8")
|  )
|
| However, I'm opening all of the .asp files in a directory using dired,
| doing a search and replace for 65001, replacing it with 65001.

Which shouldn't do anything:  Emacs by default saves files in the same
encoding that it reads them in.

| The first line of all my .asp files is:
|  <%@ Language=VBScript CodePage=65001 %>
|
| I then save all the files, but when I open one with notepad and do a
| save as, ANSI is the default Encoding, leading me to think that they
| aren't being saved as UTF8.

Uh, I haven't the faintest notion how notepad determines the encoding
of a file.

| I'm using NTEmacs 21.3.1.  Alternatively, if someone knows of a
| quick way to change the Encoding of a bunch of files to UTF8 in
| Windows XP, I'm all ears.

I just whipped up this function for you:

(defun change-encoding-to-utf8 (dir pattern)
  (interactive "DChange files to UTF-8 encoding in directory: 
sMatching file pattern (regexp): ")
  (let ((files (directory-files dir t pattern)))
    (mapc (lambda (file)
	    (find-file file)
	    (set-buffer-file-coding-system 'utf-8)
	    (save-buffer)
	    (kill-buffer (current-buffer)))
	  files)))

Define the function by putting the cursor behind the final parenthesis
and hitting C-x C-e.  Then run

M-x change-encoding-to-utf8 RET (speficy directory) RET .*[.]asd$ RET

(don't type any of the spaces - ".*[.]asd$" is a regexp matching
".asd" at the end of a filename.)

No guarantees, and backup your files before you try this.
But I did try it, and didn't see any troubles.

-- 
* Harald Hanche-Olsen     <URL:http://www.math.ntnu.no/~hanche/>
- It is undesirable to believe a proposition
  when there is no ground whatsoever for supposing it is true.
  -- Bertrand Russell

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

* Re: How to get emacs to save files as UTF8
  2006-07-28 18:21 How to get emacs to save files as UTF8 eric.goforth
  2006-07-28 20:31 ` Harald Hanche-Olsen
@ 2006-07-29 16:06 ` Ismael Valladolid Torres
  1 sibling, 0 replies; 3+ messages in thread
From: Ismael Valladolid Torres @ 2006-07-29 16:06 UTC (permalink / raw)


eric.goforth@gmail.com escribe:
> I'm using NTEmacs 21.3.1.  Alternatively, if someone knows of a quick
> way to change the Encoding of a bunch of files to UTF8 in Windows XP,
> I'm all ears.

Try iconv, it's available in any default Cygwin setup.

Cordially, Ismael
-- 
Dropping science like when Galileo dropped his orange!

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

end of thread, other threads:[~2006-07-29 16:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-07-28 18:21 How to get emacs to save files as UTF8 eric.goforth
2006-07-28 20:31 ` Harald Hanche-Olsen
2006-07-29 16:06 ` Ismael Valladolid Torres

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