diff options
Diffstat (limited to 'devdocs/elisp/translation-of-characters.html')
| -rw-r--r-- | devdocs/elisp/translation-of-characters.html | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/devdocs/elisp/translation-of-characters.html b/devdocs/elisp/translation-of-characters.html new file mode 100644 index 00000000..b7a60079 --- /dev/null +++ b/devdocs/elisp/translation-of-characters.html @@ -0,0 +1,25 @@ + <h3 class="section">Translation of Characters</h3> <p>A <em>translation table</em> is a char-table (see <a href="char_002dtables">Char-Tables</a>) that specifies a mapping of characters into characters. These tables are used in encoding and decoding, and for other purposes. Some coding systems specify their own particular translation tables; there are also default translation tables which apply to all other coding systems. </p> <p>A translation table has two extra slots. The first is either <code>nil</code> or a translation table that performs the reverse translation; the second is the maximum number of characters to look up for translating sequences of characters (see the description of <code>make-translation-table-from-alist</code> below). </p> <dl> <dt id="make-translation-table">Function: <strong>make-translation-table</strong> <em>&rest translations</em> +</dt> <dd> +<p>This function returns a translation table based on the argument <var>translations</var>. Each element of <var>translations</var> should be a list of elements of the form <code>(<var>from</var> . <var>to</var>)</code>; this says to translate the character <var>from</var> into <var>to</var>. </p> <p>The arguments and the forms in each argument are processed in order, and if a previous form already translates <var>to</var> to some other character, say <var>to-alt</var>, <var>from</var> is also translated to <var>to-alt</var>. </p> +</dd> +</dl> <p>During decoding, the translation table’s translations are applied to the characters that result from ordinary decoding. If a coding system has the property <code>:decode-translation-table</code>, that specifies the translation table to use, or a list of translation tables to apply in sequence. (This is a property of the coding system, as returned by <code>coding-system-get</code>, not a property of the symbol that is the coding system’s name. See <a href="coding-system-basics">Basic Concepts of Coding Systems</a>.) Finally, if <code>standard-translation-table-for-decode</code> is non-<code>nil</code>, the resulting characters are translated by that table. </p> <p>During encoding, the translation table’s translations are applied to the characters in the buffer, and the result of translation is actually encoded. If a coding system has property <code>:encode-translation-table</code>, that specifies the translation table to use, or a list of translation tables to apply in sequence. In addition, if the variable <code>standard-translation-table-for-encode</code> is non-<code>nil</code>, it specifies the translation table to use for translating the result. </p> <dl> <dt id="standard-translation-table-for-decode">Variable: <strong>standard-translation-table-for-decode</strong> +</dt> <dd><p>This is the default translation table for decoding. If a coding system specifies its own translation tables, the table that is the value of this variable, if non-<code>nil</code>, is applied after them. </p></dd> +</dl> <dl> <dt id="standard-translation-table-for-encode">Variable: <strong>standard-translation-table-for-encode</strong> +</dt> <dd><p>This is the default translation table for encoding. If a coding system specifies its own translation tables, the table that is the value of this variable, if non-<code>nil</code>, is applied after them. </p></dd> +</dl> <dl> <dt id="translation-table-for-input">Variable: <strong>translation-table-for-input</strong> +</dt> <dd> +<p>Self-inserting characters are translated through this translation table before they are inserted. Search commands also translate their input through this table, so they can compare more reliably with what’s in the buffer. </p> <p>This variable automatically becomes buffer-local when set. </p> +</dd> +</dl> <dl> <dt id="make-translation-table-from-vector">Function: <strong>make-translation-table-from-vector</strong> <em>vec</em> +</dt> <dd> +<p>This function returns a translation table made from <var>vec</var> that is an array of 256 elements to map bytes (values 0 through #xFF) to characters. Elements may be <code>nil</code> for untranslated bytes. The returned table has a translation table for reverse mapping in the first extra slot, and the value <code>1</code> in the second extra slot. </p> <p>This function provides an easy way to make a private coding system that maps each byte to a specific character. You can specify the returned table and the reverse translation table using the properties <code>:decode-translation-table</code> and <code>:encode-translation-table</code> respectively in the <var>props</var> argument to <code>define-coding-system</code>. </p> +</dd> +</dl> <dl> <dt id="make-translation-table-from-alist">Function: <strong>make-translation-table-from-alist</strong> <em>alist</em> +</dt> <dd><p>This function is similar to <code>make-translation-table</code> but returns a complex translation table rather than a simple one-to-one mapping. Each element of <var>alist</var> is of the form <code>(<var>from</var> +. <var>to</var>)</code>, where <var>from</var> and <var>to</var> are either characters or vectors specifying a sequence of characters. If <var>from</var> is a character, that character is translated to <var>to</var> (i.e., to a character or a character sequence). If <var>from</var> is a vector of characters, that sequence is translated to <var>to</var>. The returned table has a translation table for reverse mapping in the first extra slot, and the maximum length of all the <var>from</var> character sequences in the second extra slot. </p></dd> +</dl><div class="_attribution"> + <p class="_attribution-p"> + Copyright © 1990-1996, 1998-2022 Free Software Foundation, Inc. <br>Licensed under the GNU GPL license.<br> + <a href="https://www.gnu.org/software/emacs/manual/html_node/elisp/Translation-of-Characters.html" class="_attribution-link">https://www.gnu.org/software/emacs/manual/html_node/elisp/Translation-of-Characters.html</a> + </p> +</div> |
