1

In my markdown file (coming from a Windows computer on which I have no control), I have several multi-byte characters.

Some text xx Some text yy Some text

In emacs, they are displayed as \221 and \222 in place of xx and yy respectively. And when I do describe character, I get this:

             position: 11 of 34 (29%), column: 10
            character:  (displayed as ) (codepoint 145, #o221, #x91)
    preferred charset: iso-8859-1 (Latin-1 (ISO/IEC 8859-1))
code point in charset: 0x91
               syntax: w    which means: word
             category: l:Latin
             to input: type "C-x 8 RET 91" or "C-x 8 RET PRIVATE USE ONE"
          buffer code: #xC2 #x91
            file code: #x91 (encoded by coding system iso-latin-1-dos)
              display: no font available

Character code properties: customize what to show
  old-name: PRIVATE USE ONE
  general-category: Cc (Other, Control)
  decomposition: (145) ('')

There are text properties here:
  charset              iso-8859-1
  fontified            t

How do I query-replace (or replace-regexp or replace-string) these characters?

I mean, when it asks me to enter the string to replace, how do I enter \221 or \222, etc.?

1 Answer 1

4

Most likely your file is actually not using latin-1, yet your Emacs tries to decode it as if it were using latin-1. Try C-x RET r windows-1252 RET to see if it fixes your problem.

If it does, you'll want to either add a -*- coding: windows-1252 -*- cookie on the first line of the file so Emacs knows how to decode it properly next time, or (the option I recommend) you can save it using another encoding such as utf-8 which has the advantage of being reasonably easy to auto-detect: with C-x RET f utf-8 RET you can set the coding-system to use when saving the file and then C-x C-s will save it using that encoding.

1
  • Perfect. After that command, it indeed showed the file correctly. Can I use the file 'normally' after that command? Do I need to convert it into a different coding system (utf-8)? How?
    – deshmukh
    Commented Dec 18, 2017 at 4:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.