From WikiChip
Difference between revisions of "mirc/identifiers/$asc"
< mirc‎ | identifiers

m (see also list of identifiers)
(Add'l examples)
 
(7 intermediate revisions by 2 users not shown)
Line 1: Line 1:
'''$asc''' is used to return the [[Unicode]] [[code point]] number for a specified character.
+
{{mirc title|$asc Identifier}}'''$asc''' returns the [[Unicode]] [[code point]] number for the character (or first character of the string).
  
 
== Synopsis ==
 
== Synopsis ==
<pre>$asc(<char>)</pre>
+
<pre>$asc(<char|string>)</pre>
 
 
 
== Switches ==
 
== Switches ==
 
None
 
None
 
 
== Parameters ==
 
== Parameters ==
<span style="display: inline-block; width: 50px;">'''char'''</span>This would be any special character, letter, or number that you wish to retrieve the [[Unicode]] [[code point]] for.
+
<span style="display: inline-block; width: 50px;">'''char'''</span>This would be any special character, letter, or number for which you wish to retrieve the [[Unicode]] [[code point]]. Only codepoints 1-65535 are valid. For codepoints above 65535, it instead returns the first UTF-8 surrogate. If the parameter is a string, the 1st character of the string is used as the 'char'. If parameter is a string, it uses only the 1st character of that string.
  
== Example ==
+
* Note: mIRC v6.35 and earlier only support codepoints 1-255
'''Echo the [[Unicode]] [[code point]] for the letter ''A'' to the active window'''
+
== Examples ==
<pre>//echo -a $asc(A)</pre>
+
'''Echo the [[Unicode]] [[code point]] for the letters ''A'' and ''a'' to the active window'''
 +
<pre>//echo -a A is $asc(A) and a is $asc(a)</pre>
  
 
'''Echo the [[Unicode]] [[code point]] for the number ''7'' to the active window'''
 
'''Echo the [[Unicode]] [[code point]] for the number ''7'' to the active window'''
 
<pre>//echo -a $asc(7)</pre>
 
<pre>//echo -a $asc(7)</pre>
  
== Compatibility ==
+
<source lang="mIRC">
Added: mIRC v4.5
+
Echo the Unicode codepoint for the lower-case 'm' because that's the first character of the string.
 +
//echo -a $asc(mIRC)
 +
 
 +
Retrieve the codepoint for any input:
 +
alias Get_Asc {
 +
  //var %a $input(type or paste any character/string or alt-NNN or alt-0NNN value,e) | echo -a the codepoint for %a  is $asc(%a)
 +
}
  
Added On: 30/06/96
+
The C parameter for the token identifiers uses the same codepoint number output by $asc():
 +
//echo -a mIRC.exe is located in folder $gettok($mircexe,-2,$asc(\))
 +
</source>
 +
<source lang="mIRC">
 +
Unicode codepoint 128286 has UTF-8 Encoding of 0xF0 0x9F 0x94 0x9F and UTF-16 Encoding of 0xD83D 0xDD1F. Translated to decimal, these numbers are UTF-8 240 159 148 159 and UTF-16 55357 56607. If you change the font to "Segoe UI Symbol" which supports viewing this emoji, you'll see a number 10 inside a box. The numbers in the displayed message are the same even if your Font doesn't correctly display the emoji. This shows that $asc sees the only the UTF-8 surrogates of the string.
  
 +
//bset &v 1 240 159 148 159 | var %a $bvar(&v,1-).text | echo -a  %a is $asc($mid(%a,1)) $asc($mid(%a,2))
 +
</source>
 +
== Compatibility ==
 +
{{mIRC compatibility|4.5}}
 
== See also ==
 
== See also ==
* [[$chr identifier - mIRC|$chr]]
+
* {{mIRC|$chr}}
* [[List of identifiers - mIRC]]
+
* {{mIRC|$gettok}}
 
 
 
 
[[Category:mIRC identifiers]]
 

Latest revision as of 15:18, 6 August 2018

$asc returns the Unicode code point number for the character (or first character of the string).

Synopsis[edit]

$asc(<char|string>)

Switches[edit]

None

Parameters[edit]

charThis would be any special character, letter, or number for which you wish to retrieve the Unicode code point. Only codepoints 1-65535 are valid. For codepoints above 65535, it instead returns the first UTF-8 surrogate. If the parameter is a string, the 1st character of the string is used as the 'char'. If parameter is a string, it uses only the 1st character of that string.

  • Note: mIRC v6.35 and earlier only support codepoints 1-255

Examples[edit]

Echo the Unicode code point for the letters A and a to the active window

//echo -a A is $asc(A) and a is $asc(a)

Echo the Unicode code point for the number 7 to the active window

//echo -a $asc(7)
Echo the Unicode codepoint for the lower-case 'm' because that's the first character of the string.
//echo -a $asc(mIRC)
 
Retrieve the codepoint for any input:
alias Get_Asc {
  //var %a $input(type or paste any character/string or alt-NNN or alt-0NNN value,e) | echo -a the codepoint for %a  is $asc(%a)
}
 
The C parameter for the token identifiers uses the same codepoint number output by $asc():
//echo -a mIRC.exe is located in folder $gettok($mircexe,-2,$asc(\))
Unicode codepoint 128286 has UTF-8 Encoding of 0xF0 0x9F 0x94 0x9F and UTF-16 Encoding of 0xD83D 0xDD1F. Translated to decimal, these numbers are UTF-8 240 159 148 159 and UTF-16 55357 56607. If you change the font to "Segoe UI Symbol" which supports viewing this emoji, you'll see a number 10 inside a box. The numbers in the displayed message are the same even if your Font doesn't correctly display the emoji. This shows that $asc sees the only the UTF-8 surrogates of the string.
 
//bset &v 1 240 159 148 159 | var %a $bvar(&v,1-).text | echo -a  %a is $asc($mid(%a,1)) $asc($mid(%a,2))

Compatibility[edit]

Added: mIRC v4.5
Added on: 30 Jun 1996
Note: Unless otherwise stated, this was the date of original functionality.
Further enhancements may have been made in later versions.

See also[edit]