|
Size: 1513
Comment:
|
Size: 1654
Comment:
|
| Deletions are marked like this. | Additions are marked like this. |
| Line 37: | Line 37: |
To use non-ASCII characters in `.rst` files, put the following at the very top of your `.rst` file: {{{ .. -*- coding: utf-8 -*- }}} |
Non-ASCII Characters
You should avoid as much as possible putting non-ASCII characters in a source file. If you're using Emacs, you can use the following function to find non-ASCII characters. It is taken from the Emacs wiki:
;; Find non-ASCII characters in source files.
(defun non-ascii-char ()
"Find the first non-ASCII character from point onwards."
(interactive)
(let (point)
(save-excursion
(setq point
(catch 'non-ascii
(while (not (eobp))
(or (eq (char-charset (following-char))
'ascii)
(throw 'non-ascii (point)))
(forward-char 1)))))
(if point
(goto-char point)
(message "No non-ASCII characters."))))Put the above function definition in your Emacs configuration file ~/.emacs. Then to use the function in an opened source file, do:
M-x non-ascii-char RET
There are situations where you need to use non-ASCII characters in source files. For example, you might want to acknowledge someone for their contribution or you want to put an author's name in a source file. The name might contain non-ASCII characters. In that case, put the following line at the top of the relevant source file:
# -*- coding: utf-8 -*-
Another case would be in doctesting functions that are meant to support unicode input, for example, in the notebook.
To use non-ASCII characters in .rst files, put the following at the very top of your .rst file:
.. -*- coding: utf-8 -*-
