CharacterMap class: Difference between revisions

From m204wiki
Jump to navigation Jump to search
mNo edit summary
 
(17 intermediate revisions by 5 users not shown)
Line 1: Line 1:
A CharacterMap class object contains a mapping of characters to characters.
A <var>CharacterMap</var> object contains a mapping of characters to characters.
Each character in an In string
Each character in an In string (the "input table") is associated with, or mapped to, an individual character
(the &ldquo;input table&rdquo;) is associated with, or mapped to, an individual character
from an Out string (the "output table").
from an Out string (the &ldquo;output table&rdquo;).
The output table may be supplemented with instances of a pad character
The output table may be supplemented with instances of a pad character
to ensure a one-to-one mapping with the input table characters.
to ensure a one-to-one mapping with the input table characters.
   
   
The methods in this class are listed in [[:Category:CharacterMap methods]].
<var>CharacterMap</var> includes a constructor, copy methods, and an update method
for modifying the map.  
CharacterMap includes a constructor, copy methods, and an update method
 
for modifying the map.
The <var>CharacterMap</var> class is new as of version 7.3 of the <var class="product">Sirius Mods</var>.
Most of these methods are shown in the following example,
 
which features the intrinsic String [[Translate (String function)|Translate]] function.
==Example==
In the example, a new CharacterMap is the argument for the Translate method;
{{Template:CharacterMap example}}
then that map is copied and modified, and the modified map is used in a
 
second Translate call:
==List of CharacterMap methods==
<pre>
The [[List of CharacterMap methods]] shows all the class methods.
    begin
 
    %map is object characterMap
    %map2 is object characterMap
    %ls is longstring
    %map = New(in='x-', out='!c')
    %ls = 'xu--exx'
    printtext {~} = '{%ls:translate(%map)}'
    %map2 = %map:Copy
    %map2:Update(in='x',out='s')
    printtext {~} = '{%ls:translate(%map2)}'
    end
</pre>
The result is:
<pre>
    %ls:translate(%map) = '!ucce!!'
    %ls:translate(%map2) = 'success'
</pre>
The methods in the class are described in the subsections that follow.
For information about the conventions followed in the method
descriptions, see [[Notation conventions for methods]].
This class is new as of version 7.3 of the ''Sirius Mods''.
[[Category:System classes]]
[[Category:System classes]]

Latest revision as of 19:05, 20 April 2018

A CharacterMap object contains a mapping of characters to characters. Each character in an In string (the "input table") is associated with, or mapped to, an individual character from an Out string (the "output table"). The output table may be supplemented with instances of a pad character to ensure a one-to-one mapping with the input table characters.

CharacterMap includes a constructor, copy methods, and an update method for modifying the map.

The CharacterMap class is new as of version 7.3 of the Sirius Mods.

Example

Most of the CharacterMap methods are shown in the following example, which also features the intrinsic String function, Translate. In the example, a new CharacterMap is the argument for the Translate method; then that map is copied and modified, and the modified map is used in a second Translate call:

begin %map is object characterMap %map2 is object characterMap %ls is longstring %map = New(in='x-', out='!c') %ls = 'xu--exx' printtext {~} = '{%ls:translate(%map)}' %map2 = %map:Copy %map2:Update(in='x',out='s') printtext {~} = '{%ls:translate(%map2)}' end

The result is:

%ls:translate(%map) = '!ucce!!' %ls:translate(%map2) = 'success'

List of CharacterMap methods

The List of CharacterMap methods shows all the class methods.