From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Harald Hanche-Olsen Newsgroups: gmane.emacs.help Subject: Re: How to get emacs to save files as UTF8 Date: Fri, 28 Jul 2006 22:31:20 +0200 Organization: Norwegian university of science and technology Message-ID: References: <1154110891.856955.287080@p79g2000cwp.googlegroups.com> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1154119342 30110 80.91.229.2 (28 Jul 2006 20:42:22 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 28 Jul 2006 20:42:22 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Jul 28 22:42:16 2006 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1G6Z9d-0007JJ-1Z for geh-help-gnu-emacs@m.gmane.org; Fri, 28 Jul 2006 22:41:53 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1G6Z9c-0003cv-Ig for geh-help-gnu-emacs@m.gmane.org; Fri, 28 Jul 2006 16:41:52 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!newsfeed1.swip.net!swipnet!newsfeed1.funet.fi!newsfeeds.funet.fi!uio.no!ntnu.no!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 58 Original-NNTP-Posting-Host: fiinbeck.math.ntnu.no Original-X-Trace: orkan.itea.ntnu.no 1154118472 8529 129.241.15.140 (28 Jul 2006 20:27:52 GMT) Original-X-Complaints-To: usenet@itea.ntnu.no Original-NNTP-Posting-Date: Fri, 28 Jul 2006 20:27:52 +0000 (UTC) User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/23.0.0 (berkeley-unix) Cancel-Lock: sha1:vLWB4gjItsDK/wqIXYP1eaPwlvU= Original-Xref: shelby.stanford.edu gnu.emacs.help:140723 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:36348 Archived-At: + 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 - It is undesirable to believe a proposition when there is no ground whatsoever for supposing it is true. -- Bertrand Russell