1

i am working with Emacs as my editor for quite a long time.

Yesterday, out of the sudden, Emacs presented me all mutated german vowels as octal numbers. I have tried some things, but nothing worked, Emacs is obviously not interested in interpreting his own setting(?). For example if i tell him to Set the language environment to german, he is still presenting octals, so that, for example a word like "für" is written as "f\303\274r", which makes the whole text unreadable, "Körpergrößen" for example is written as "K\303\266rpergr\303\266\303\237en" which makes the whole text worthless for editing.

This octals are shown in the old text, if i write new mutated umlaute, then they are disappearing if i save and open it again !?

regards

p.s.: the category "init-file" is only chosen because otherwise i could not post this question.... pps.: i am working on Windows 7

10
  • What version of Emacs are you using? Where did you get it exactly? Do you have the same problem if you start Emacs without your init file (emacs -q)? Jul 23, 2019 at 6:51
  • @Gilles, i´ve already solved this problem. Out of curiosity: is there a difference in handling special characters within the different emacs versions?
    – Coliban
    Jul 23, 2019 at 7:22
  • I don't think there's been changes in how Emacs handles non-ASCII characters recently. But different versions or builds on Emacs may have different rules for the default encoding. Jul 23, 2019 at 7:29
  • Wait a minute sorry, it is GNU Emacs 26.1 on Windows 7. While i had no problems before (first on Unix, now on Windows 7) the presentation changed out of the sudden
    – Coliban
    Jul 23, 2019 at 7:35
  • 2
    As a temporary workaround, after opening a file, press C-x RET r and select utf-8. Jul 23, 2019 at 7:44

1 Answer 1

0

The solution is to "tell" Emacs to load the file as UTF-8:

-*- coding: utf-8; mode: xub -*- 

(As the first line of the file)

Workaround

I searched a lot and there is no answer to this question or, perhaps better, i didn´t found one. While I still not knowing why this happened, I was fed up searching for a solution so I choose "brute force" and exchanged all octets to their corresponding correct values:

(defun mumlaute ()
"Fixing wrong mutated German vowels"
(interactive "*")
(save-excursion
(goto-char (point-min))
(while (re-search-forward "\303\244" nil t) (replace-match "ä" t nil))
(goto-char (point-min))
(while (re-search-forward "\303\266" nil t) (replace-match "ö" t nil))
(goto-char (point-min))
(while (re-search-forward "\303\274" nil t) (replace-match "ü" t nil))
(goto-char (point-min))
(while (re-search-forward "\303\237" nil t) (replace-match "ß" t nil))
))

I spend some time trying to replace the octets until i recognized that it is not sufficient to write the octets down, because they are chars, for example a "ä" represented (wrong) in emacs is "\303\244" cannot typed, it has to be copied and pasted because that are not 8 chars, it is only two chars ( ) not printable....

regards

p.s.: if I post the original character then they are not displayed here because they are special characters, so i changed the original chars to the corresponding ascii representation here which is printable. If someone would copy and paste this code it would be not working because he/she would have to change the characters here to the corresponding not printable codes...

4
  • The code you posted replaces sequences of two spaces by ä. That's not what you meant to do, but it illustrates that your “fix” isn't one. You're probably changing the encoding of your files, which means you may not be able to read them back. You should really fix the actual problem, which is that Emacs isn't using the encoding that you intended. Jul 23, 2019 at 7:31
  • I could/should write the corresponding string. The "two spaces" are indeed two characters which are not printed here.
    – Coliban
    Jul 23, 2019 at 7:33
  • It seems like this is much harder than doing C-x C-m r utf-8 RET. Does it really solve the problem permanently?
    – npostavs
    Jul 25, 2019 at 0:13
  • 1
    @npostavs: no, you are right. It was only a temporary solution for this problem. To fix it permanent, s.o. would put the line -*- coding: utf-8; mode: xub -*- as the first line of the file.
    – Coliban
    Jul 25, 2019 at 7:32

Your Answer

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

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