1654
Comment:
|
← Revision 4 as of 2022-04-18 04:07:29 ⇥
0
outdated with python3
|
Deletions are marked like this. | Additions are marked like this. |
Line 1: | Line 1: |
= 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 [[http://www.emacswiki.org/emacs/FindingNonAsciiCharacters | 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 -*- }}} |