NewFromAsciiCodepage (CharacterToUnicodeMap function): Difference between revisions
m (→Examples) |
|||
(2 intermediate revisions by 2 users not shown) | |||
Line 18: | Line 18: | ||
==Usage notes== | ==Usage notes== | ||
<ul> | <ul> | ||
<li>The only allowed values of the <var class="term">codepageName</var> argument are <code>1250</code> and <code>1252</code>. | |||
<li><var>NewFromAsciiCodepage</var> is a [[Object variables#Virtual Constructor methods|virtual constructor]] and as such can be called with no method object, with an explicit class name, or with an object variable, even if that object is null: | <li><var>NewFromAsciiCodepage</var> is a [[Object variables#Virtual Constructor methods|virtual constructor]] and as such can be called with no method object, with an explicit class name, or with an object variable, even if that object is null: | ||
<p class="code">%charToUmap = newFromAsciiCodepage('1252') | <p class="code">%charToUmap = newFromAsciiCodepage('1252') | ||
Line 24: | Line 25: | ||
%charToUmap = %charToUmap:newFromAsciiCodepage('1252') | %charToUmap = %charToUmap:newFromAsciiCodepage('1252') | ||
<li>The only two codepages supported as input parameters to <var>NewFromAsciiCodepage</var> are '1250' and 1252'. | |||
</p> | </p> | ||
</ul> | </ul> | ||
Line 36: | Line 38: | ||
Printtext {~} is {%u:UnicodeToUtf16:StringToHex} </p> | Printtext {~} is {%u:UnicodeToUtf16:StringToHex} </p> | ||
The result is: <code>%u:UnicodeToUtf16:StringToHex is 20AC</ | The result is: | ||
<p class="code">%u:UnicodeToUtf16:StringToHex is 20AC</p> | |||
==See also== | ==See also== | ||
{{Template:CharacterToUnicodeMap:NewFromAsciiCodepage footer}} | {{Template:CharacterToUnicodeMap:NewFromAsciiCodepage footer}} |
Latest revision as of 15:34, 3 October 2013
Create CharacterToUnicodeMap object from ASCII codepage (CharacterToUnicodeMap class)
[Introduced in Sirius Mods 8.0]
This method lets you dynamically select a particular codepage for specific data needs without
having to change your system-wide codepage.
Syntax
%characterToUnicodeMap = [%(CharacterToUnicodeMap):]NewFromAsciiCodepage( codepageName)
Syntax terms
%CharacterToUnicodeMap | A CharacterToUnicodeMap object. |
---|---|
[%(CharacterToUnicodeMap):] | The optional class name in parentheses denotes a virtual constructor. See "Usage notes", below, for more information about invoking a virtual constructor. |
codepageName | A string that identifies one of the currently supported codepages at your site. You can view (and manage) these codepages with the UNICODE command. |
Usage notes
- The only allowed values of the codepageName argument are
1250
and1252
. - NewFromAsciiCodepage is a virtual constructor and as such can be called with no method object, with an explicit class name, or with an object variable, even if that object is null:
%charToUmap = newFromAsciiCodepage('1252') %charToUmap = %(CharacterToUnicodeMap):newFromAsciiCodepage('1252') %charToUmap = %charToUmap:newFromAsciiCodepage('1252')
- The only two codepages supported as input parameters to NewFromAsciiCodepage are '1250' and 1252'.
Examples
The following code sequence shows the use of an ASCII codepage (available with Sirius Mods 8.0), which maps the ASCII X'80' character (normally the Euro sign) to the Unicode character for the Euro, U+20AC:
%tr is object characterToUnicodeMap %tr = newFromAsciiCodepage('1252') %u = ('80':x):characterToUnicode(%tr) Printtext {~} is {%u:UnicodeToUtf16:StringToHex}
The result is:
%u:UnicodeToUtf16:StringToHex is 20AC