From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: ken Newsgroups: gmane.emacs.help Subject: Re: How to get rid of Microsoft dumb quotes, e.g. \222 for apostrophe? Date: Sat, 17 Feb 2007 06:04:52 -0500 Message-ID: <45D6E154.8040706@speakeasy.net> References: <1171628373.417583.61410@k78g2000cwa.googlegroups.com> <87zm7e8e7j.fsf@wivenhoe.staff8.ul.ie> <45D5D58F.2050900@speakeasy.net> <87hctmgjur.fsf@patagonia.sebmags.homelinux.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1171710341 1014 80.91.229.12 (17 Feb 2007 11:05:41 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sat, 17 Feb 2007 11:05:41 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Feb 17 12:05:21 2007 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1HINNX-00045j-Fh for geh-help-gnu-emacs@m.gmane.org; Sat, 17 Feb 2007 12:05:20 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HINNW-0003OC-Sk for geh-help-gnu-emacs@m.gmane.org; Sat, 17 Feb 2007 06:05:18 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1HINNL-0003Np-0l for help-gnu-emacs@gnu.org; Sat, 17 Feb 2007 06:05:07 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1HINNK-0003N8-Dn for help-gnu-emacs@gnu.org; Sat, 17 Feb 2007 06:05:06 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HINNK-0003N5-6v for help-gnu-emacs@gnu.org; Sat, 17 Feb 2007 06:05:06 -0500 Original-Received: from mail5.sea5.speakeasy.net ([69.17.117.7]) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA:32) (Exim 4.52) id 1HINNJ-00044r-Jn for help-gnu-emacs@gnu.org; Sat, 17 Feb 2007 06:05:05 -0500 Original-Received: (qmail 31609 invoked from network); 17 Feb 2007 11:05:02 -0000 Original-Received: from dsl093-011-017.cle1.dsl.speakeasy.net (HELO [192.168.0.27]) (gebser@[66.93.11.17]) (envelope-sender ) by mail5.sea5.speakeasy.net (qmail-ldap-1.03) with AES256-SHA encrypted SMTP for ; 17 Feb 2007 11:05:02 -0000 User-Agent: Thunderbird 1.5.0.9 (X11/20061206) In-Reply-To: <87hctmgjur.fsf@patagonia.sebmags.homelinux.org> X-Enigmail-Version: 0.94.1.1 OpenPGP: id=45796D04 X-detected-kernel: Linux 2.6, seldom 2.4 (older, 4) 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:41284 Archived-At: On 02/16/2007 11:14 AM somebody named Sebastian P. Luque wrote: > On Fri, 16 Feb 2007 11:02:23 -0500, > ken wrote: > > [...] > >> This allows, or should allow, the binding of the function to a key >> chord. But something is not right. Can anyone tell where the problem >> is. Running this function I get no errors, but the garbage/mschars are >> not replaced. > > I can't tell what is wrong with that code, but I've solved those issues > with this (I lost track where I stole this from): > > > (standard-display-ascii ?\200 (vector (decode-char 'ucs #x253c))) > (standard-display-ascii ?\201 (vector (decode-char 'ucs #x251c))) > (standard-display-ascii ?\202 (vector (decode-char 'ucs #x252c))) > (standard-display-ascii ?\203 (vector (decode-char 'ucs #x250c))) > (standard-display-ascii ?\204 (vector (decode-char 'ucs #x2524))) > (standard-display-ascii ?\205 (vector (decode-char 'ucs #x2502))) > (standard-display-ascii ?\206 (vector (decode-char 'ucs #x2510))) > (standard-display-ascii ?\210 (vector (decode-char 'ucs #x2534))) > (standard-display-ascii ?\211 (vector (decode-char 'ucs #x2514))) > (standard-display-ascii ?\212 (vector (decode-char 'ucs #x2500))) > (standard-display-ascii ?\214 (vector (decode-char 'ucs #x2518))) > (standard-display-ascii ?\220 [? ]) > (standard-display-ascii ?\221 [?\` ]) > (standard-display-ascii ?\222 [?\']) > (standard-display-ascii ?\223 [?\"]) > (standard-display-ascii ?\224 [?\"]) > (standard-display-ascii ?\225 "* ") > (standard-display-ascii ?\226 "--") > (standard-display-ascii ?\227 " -- ") Thanks, Seb. As I understand this code (and, frankly, I don't totally), it will handle single-character substrings only. MS and other files frequently contain multi-byte characters which appear in emacs as a string of garbage characters. (See example in my previous post.) While of course it's best to write code which doesn't exceed the capabilities of the programming language, it's pretty much a mark of a mature programming language that it has the capability to programmatically search-and-replace multi-byte strings in a file, even should the sought- and replacement-strings be of different lengths. In fact, I made just this sort of function a homework assignment in my C Programming 101 class many years ago. So it's rather mystifying to me, especially given the prevalence of the need for such functionality, that such a trivial bit of programming is such a challenge in elisp. Maybe I'll take another run at it later. Best, ken