help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to get rid of Microsoft dumb quotes, e.g. \222 for apostrophe?


From: ken
Subject: Re: How to get rid of Microsoft dumb quotes, e.g. \222 for apostrophe?
Date: Sat, 17 Feb 2007 06:04:52 -0500
User-agent: Thunderbird 1.5.0.9 (X11/20061206)

On 02/16/2007 11:14 AM somebody named Sebastian P. Luque wrote:
> On Fri, 16 Feb 2007 11:02:23 -0500,
> ken <gebser@speakeasy.net> 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





reply via email to

[Prev in Thread] Current Thread [Next in Thread]