Elisp: Replace Invisible Unicode Chars
Here's a command that replaces annoying invisible characters.
For example,
- ZERO WIDTH NO-BREAK SPACE (65279, #xfeff)
- RIGHT-TO-LEFT MARK (8207, #x200f)
- RIGHT-TO-LEFT OVERRIDE (8238, #x202e)
- LEFT-TO-RIGHT MARK (8206, #x200e)
They happen when copying text from Twitter etc sites.
(defun xah-replace-invisible-char () "Query replace some invisible Unicode chars. The chars to be searched are: ZERO WIDTH NO-BREAK SPACE (65279, #xfeff) RIGHT-TO-LEFT MARK (8207, #x200f) RIGHT-TO-LEFT OVERRIDE (8238, #x202e) LEFT-TO-RIGHT MARK (8206, #x200e) OBJECT REPLACEMENT CHARACTER (65532, #xfffc) Search begins at cursor position. (respects `narrow-to-region') URL `http://ergoemacs.org/emacs/elisp_unicode_replace_invisible_chars.html' Version 2018-03-05" (interactive) (query-replace-regexp "\u200f\\|\u202e\\|\ufeff\\|\u200e\\|\ufffc" ""))
See also: Emacs: Unicode Tutorial
Patreon me $5. Ask me question on patreon