|
From: | Stefan Monnier |
Subject: | Re: How to get rid of Microsoft dumb quotes, e.g. \222 for apostrophe? |
Date: | Fri, 16 Feb 2007 20:47:11 -0500 |
User-agent: | Gnus/5.11 (Gnus v5.11) Emacs/22.0.93 (gnu/linux) |
> (while (re-search-forward "[-]" nil t) > (let ((mschar (buffer-substring-no-properties > (match-beginning 0) (match-end 0)))) > (cond > ((string= mschar "") (replace-match "`" )) > ((string= mschar "") (replace-match "'" )) > ((string= mschar "") (replace-match "``")) > ((string= mschar "") (replace-match "''")) > ((string= mschar "") (replace-match "--"))))) Better work on chars rather than strings of one-char. Also better not use those special chars that are sometimes displayed as \200 and use the \ 2 0 0 escape sequence instead: (require 'cl) (defun my-fun-foo () (interactive) (goto-char (point-min)) (while (re-search-forward "[\200-\237]" nil t) (case (char-before) (?\221 (replace-match "`" )) (?\222 (replace-match "'" )) (?\233 (replace-match "``")) (?\224 (replace-match "''")) (?\226 (replace-match "--"))))) -- Stefan PS: Guaranteed 100% untested.
[Prev in Thread] | Current Thread | [Next in Thread] |