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

(Created page with "{{mirc title|$upper Identifier}}'''$upper''' returns text in upper case == Synopsis == <pre>$upper(text)</pre> == Paramters == * '''text''' - the text you want in uppercas...")
 
 
Line 1: Line 1:
 
{{mirc title|$upper Identifier}}'''$upper''' returns text in upper case
 
{{mirc title|$upper Identifier}}'''$upper''' returns text in upper case
 
 
 
== Synopsis ==
 
== Synopsis ==
 
<pre>$upper(text)</pre>
 
<pre>$upper(text)</pre>
 
+
== Parameters ==
== Paramters ==
 
 
 
 
* '''text''' - the text you want in uppercase
 
* '''text''' - the text you want in uppercase
 
 
== Properties ==
 
== Properties ==
 
None
 
None
 
 
== Example ==
 
== Example ==
 
<source lang="mIRC">//echo -a $upper(ab)</source>
 
<source lang="mIRC">//echo -a $upper(ab)</source>
  
 +
Note: A-Z and a-z are the only ranges of characters which the == and != operators consider to be case-insensitive equivalents of each other. However $upper $lower $isupper and $islower and the operators isupper and islower also consider 1894 codepoints in the range 192-65535 to have an uppercase or lowercase versions of themselves. This next command displays 1946 lines showing all codepoints affected by either $upper or $lower:
 +
 +
<source lang="mIRC">
 +
//var %i 1 , %c 0 | while (%i isnum 1-65535) { var -p %a $chr(%i) , %v1 %a %a , %v2 $upper(%a) $lower(%a) | if (%v1 !=== %v2) { inc %c | echo -a $ord(%c) codepoint %i is $chr(%i) upper is codepoint $asc($upper(%a)) $upper(%a) lower is codepoint $asc($lower(%a)) $lower(%a) } | inc %i }
 +
</source>
 +
 +
If you edit the above command by changing !=== to != you can see the display shows 1894 rows instead of 1946. The difference is caused by the case-insensitive != operator viewing only the A-Z a-z ranges among those affected by $upper or $lower to be case-insensitive equivalents of each other.
 +
 +
If it's essential that your code changes ONLY the A-Z a-z ranges, use the aliases below. If you edit the above command to use $upper26() and $lower26() in place of $upper() and $lower(), the 1946-line display changes to show only the 52 characters in the A-Z a-z ranges:
 +
 +
<source lang="mIRC">
 +
//echo -a $upper($chr(233)) vs $lower($chr(233))
 +
result: É vs é
 +
//echo -a $upper26($chr(233)) vs $lower26($chr(233))
 +
result: é vs é
 +
</source>
 +
 +
<source lang="mIRC">
 +
alias upper26 { returnex $regsubex($1,/([a-z])/g,$chr($calc($asc(\t) -32))) }
 +
alias lower26 { returnex $regsubex($1,/([A-Z])/g,$chr($calc($asc(\t) +32))) }
 +
</source>
 
== Compatibility ==
 
== Compatibility ==
 
{{mIRC compatibility|4.5}}
 
{{mIRC compatibility|4.5}}
 
 
== See Also ==
 
== See Also ==
{{mIRC|$lower}}
+
{{collist
{{mIRC|$isupper}}
+
|count = 4
 
+
|style = width: 100%; display: inherit;
[[Category:mIRC identifiers]]
+
|
 +
* {{mIRC|$lower}}
 +
* {{mIRC|$isupper}}
 +
* {{mIRC|$islower}}
 +
* {{mIRC|operators}}
 +
}}

Latest revision as of 23:14, 24 November 2018

$upper returns text in upper case

Synopsis[edit]

$upper(text)

Parameters[edit]

  • text - the text you want in uppercase

Properties[edit]

None

Example[edit]

//echo -a $upper(ab)

Note: A-Z and a-z are the only ranges of characters which the == and != operators consider to be case-insensitive equivalents of each other. However $upper $lower $isupper and $islower and the operators isupper and islower also consider 1894 codepoints in the range 192-65535 to have an uppercase or lowercase versions of themselves. This next command displays 1946 lines showing all codepoints affected by either $upper or $lower:

//var %i 1 , %c 0 | while (%i isnum 1-65535) { var -p %a $chr(%i) , %v1 %a %a , %v2 $upper(%a) $lower(%a) | if (%v1 !=== %v2) { inc %c | echo -a $ord(%c) codepoint %i is $chr(%i) upper is codepoint $asc($upper(%a)) $upper(%a) lower is codepoint $asc($lower(%a)) $lower(%a) } | inc %i }

If you edit the above command by changing !=== to != you can see the display shows 1894 rows instead of 1946. The difference is caused by the case-insensitive != operator viewing only the A-Z a-z ranges among those affected by $upper or $lower to be case-insensitive equivalents of each other.

If it's essential that your code changes ONLY the A-Z a-z ranges, use the aliases below. If you edit the above command to use $upper26() and $lower26() in place of $upper() and $lower(), the 1946-line display changes to show only the 52 characters in the A-Z a-z ranges:

//echo -a $upper($chr(233)) vs $lower($chr(233))
result: É vs é
//echo -a $upper26($chr(233)) vs $lower26($chr(233))
result: é vs é
alias upper26 { returnex $regsubex($1,/([a-z])/g,$chr($calc($asc(\t) -32))) }
alias lower26 { returnex $regsubex($1,/([A-Z])/g,$chr($calc($asc(\t) +32))) }

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]