Reputation: 2120
I am new to Windows and when pasting text snippets from some Windows applications into Emacs I have problems saving the file. It seems that my encoding is typically iso-latin-1-dos (I do not set it explicitely anywhere, I do not require it to be that) and umlaut characters (üöä...) do not cause any problems.
Here is an example of error message:
These default coding systems were tried to encode text
in the buffer `wdiary.org':
(iso-latin-1-dos (22406 . 8226) (22438 . 8226) (22469 . 8226) (22528
. 8226) (22576 . 8226) (22680 . 8226) (22759 . 8220) (22841 . 8221)
(22905 . 8217) (23081 . 8226) (23192 . 8226))
However, each of them encountered characters it couldn't encode:
iso-latin-1-dos cannot encode these: • • • • • • “ ” ’ • ...
Selecting utf-8 gives the same result.
Examples of problematic characters (they are displayed correctly but file refuses to save):
• ‣ …
How can I save a file containnig these characters?
Possibility would be an automatic replacing of the characters with standard symbols on paste (or latest on save), e.g. map any bullet symbol to -
. It would seem Xah Lee's zap_gremlins is along those lines, but the question is how am I supposed to save his file too since it will contain the offending characters.
Thank you very much!
Upvotes: 1
Views: 537
Reputation: 2120
I finally solved it in the following way:
force UTF-8 on the file with offending symbols by adding in the first line:
# -*- coding: utf-8 -*-
With this it can be saved normally.
(prefer-coding-system 'utf-8)
(setq x-select-request-type '(UTF8_STRING COMPOUND_TEXT TEXT STRING))
Which will set the encoding for new buffers. Finally swapping can be done with Xah Lee's script (but using utf-8 makes this not necessary).
Upvotes: 2