reddit / emacs

Please help with char / encoding issue.

rtwyyn · 2022-09-24 23:30
I copy pasted text (quotes) from pdf file, saved file, everything seemed fine, but now any time i try to edit file - let say i add . or , or ? and try to save it it shows following: ​ These default coding systems were tried to encode the following problematic characters in the buffer ‘ *temp*’: Coding System Pos Codepoint Char iso-latin-1-dos 35873 #x2014 — 36355 #x2014 — 36639 #x2014 — However, each of them encountered characters it couldn’t encode: iso-latin-1-dos cannot encode these: — — — Click on a character (or switch to this window by ‘C-e o’ and select the characters by RET) to jump to the place it appears, where ‘C-u C-e =’ will give information about it. Select one of the safe coding systems listed below, or cancel the writing with C-g and edit the buffer to remove or modify the problematic characters, or specify any other coding system (and risk losing the problematic characters). utf-8 shift_jis iso-2022-jp big5 euc-jis-2004 euc-jp euc-tw windows-1256 windows-1258 cp874 iso-2022-jp-2004 windows-1255 windows-1253 adobe-standard-encoding hp-roman8 next macintosh windows-1257 windows-1254 windows-1252 windows-1250 windows-1251 koi8-t gb18030 gbk big5-hkscs utf-7 utf-16 utf-16be-with-signature utf-16le-with-signature utf-16be utf-16le iso-2022-7bit utf-8-auto utf-8-with-signature eucjp-ms georgian-academy georgian-ps japanese-shift-jis-2004 japanese-iso-7bit-1978-irv pt154 utf-7-imap utf-8-emacs prefer-utf-8 I tried to search for "—", but it's not anywhere in the text...
eli-zaretskii · 2022-09-25 05:17
Try this: `C-x RET f utf-8 RET`. This changes the buffer's file encoding to UTF-8, and should allow you to save the buffer. In general, the text you show is there to explain what happened, but it also asks you for the suitable encoding to save the buffer -- that's the "Select one of the safe coding systems listed below" part (and note that "utf-8" is the first in the list). So whenever you see it, just select the encoding, and Emacs will save the buffer.
rtwyyn · 2022-09-25 10:18
Thank you for reply, it was different thing - "—" character was not in file itself, but in its undo-tree history. Once i modified history file (replaced "—" with "-") i issue was solved.