all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Harald Hanche-Olsen <hanche@math.ntnu.no>
Subject: Re: How to get emacs to save files as UTF8
Date: Fri, 28 Jul 2006 22:31:20 +0200	[thread overview]
Message-ID: <pcomzatv5d3.fsf@shuttle.math.ntnu.no> (raw)
In-Reply-To: 1154110891.856955.287080@p79g2000cwp.googlegroups.com

+ 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

  reply	other threads:[~2006-07-28 20:31 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-07-28 18:21 How to get emacs to save files as UTF8 eric.goforth
2006-07-28 20:31 ` Harald Hanche-Olsen [this message]
2006-07-29 16:06 ` Ismael Valladolid Torres

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

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

  git send-email \
    --in-reply-to=pcomzatv5d3.fsf@shuttle.math.ntnu.no \
    --to=hanche@math.ntnu.no \
    /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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.