Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I searched high and low but it seems Emacs (or at least version 24.3.1) doesn't have such a function. Nor can I find it somewhere.</p> <p>Based on a <a href="https://github.com/jkarlsson/emacs-config/blob/master/vendor/ys-xml-escape.el" rel="nofollow">similar</a> (but different) function I did find, I implemented it myself:</p> <pre><code>(require 'cl) (defun html-nonascii-to-entities (string) "Replace any non-ascii characters with HTML (actually SGML) entity codes." (mapconcat #'(lambda (char) (case char (t (if (and (&lt;= 8 char) (&lt;= char 126)) (char-to-string char) (format "&amp;#%02d;" char))))) string "")) (defun html-nonascii-to-entities-region (region-begin region-end) "Replace any non-ascii characters with HTML (actually SGML) entity codes." (interactive "r") (save-excursion (let ((escaped (html-nonascii-to-entities (buffer-substring region-begin region-end)))) (delete-region region-begin region-end) (goto-char region-begin) (insert escaped)))) </code></pre> <p>I'm no Elisp guru at all, but this works!</p> <p>I also found <a href="http://www.emacswiki.org/FindingNonAsciiCharacters" rel="nofollow">find-next-unsafe-char</a> to be of value.</p> <p><strong>Edit:</strong> an interactive version!</p> <pre><code>(defun query-replace-nonascii-with-entities () "Replace any non-ascii characters with HTML (actually SGML) entity codes." (interactive) (perform-replace "[^[:ascii:]]" `((lambda (data count) (format "&amp;#%02d;" ; Hex: "&amp;#x%x;" (string-to-char (match-string 0))))) t t nil)) </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload