CharacterToUnicodeMap class: Difference between revisions
mNo edit summary |
m (→Example) |
||
Line 16: | Line 16: | ||
==Example== | ==Example== | ||
The following request generates a basic ASCII to Unicode codepage, then converts | The following request generates a basic ASCII to Unicode codepage, then converts | ||
the ASCII '01234' characters to Unicode. If you | the ASCII '01234' equivalent hex characters to Unicode. If you | ||
attempt to extract a translation of a code point not in the mapping, say an ASCII code point with the high order bit on like X'80', you get a <var>[[CharacterTranslationException class|CharacterTranslationException]]</var> exception: | attempt to extract a translation of a code point not in the mapping, say an ASCII code point with the high order bit on like X'80', you get a <var>[[CharacterTranslationException class|CharacterTranslationException]]</var> exception: | ||
<p class="code">b | <p class="code">b |
Revision as of 19:00, 2 December 2011
A CharacterToUnicodeMap object contains a mapping of single-byte code points to Unicode (double-byte) characters. The single-byte characters are presumably EBCDIC or ASCII, though the class does not explicitly require this — it simply maps code points in some character set to Unicode.
The CharacterToUnicodeMap class provides programmers with a facility for creating or copying codepages that are not currently available in the current Sirius Mods version. Besides methods for creating and modifying your own codepage, the class also has methods for dynamically invoking one of the Sirius Mods codepages supported at your site.
The "List of CharacterToUnicodeMap methods" shows all the class methods.
You can use the String class CharacterToUnicode method to produce the mapped Unicode characters for the string characters you specify.
The CharacterToUnicodeMap class is new as of version 8.0 of the Sirius Mods.
Example
The following request generates a basic ASCII to Unicode codepage, then converts the ASCII '01234' equivalent hex characters to Unicode. If you attempt to extract a translation of a code point not in the mapping, say an ASCII code point with the high order bit on like X'80', you get a CharacterTranslationException exception:
b %i is float %l is longstring %u is unicode %tr is object characterToUnicodeMap for %i from 0 to 127 %l = %l with %i:integerToBinary(1) %u = %u:unicodeWith(%i:integerToBinary(2):utf16ToUnicode) end for %tr = new(in=%l, out=%u) printText {'3031323334':x:characterToUnicode(%tr)} end