mIRC Home    About    Download    Register    News    Help

Print Thread
#209140 05/02/09 12:20 AM
Joined: Oct 2005
Posts: 827
P
pouncer Offline OP
Hoopy frood
OP Offline
Hoopy frood
P
Joined: Oct 2005
Posts: 827
if this has been locked on mIRC, how can i enable it via code on start?

or what if a user is using a realy old version of mirc where $utfdecode wasnt supported, how can i find this out via code?

Last edited by pouncer; 05/02/09 12:23 AM.
pouncer #209141 05/02/09 12:41 AM
Joined: Jul 2006
Posts: 4,157
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,157
$utfdecode was introduced in mIRC 6.32, so you can check for $version.
The only way to enable this sort of thing is to use sendkey


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Wims #209161 05/02/09 12:10 PM
Joined: Oct 2005
Posts: 827
P
pouncer Offline OP
Hoopy frood
OP Offline
Hoopy frood
P
Joined: Oct 2005
Posts: 827
Originally Posted By: Wims
$utfdecode was introduced in mIRC 6.32


I tried $utfdecode in 6.31 and it works there too

pouncer #209162 05/02/09 12:13 PM
Joined: Jul 2006
Posts: 4,157
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,157
Indeed, don't know why I've seen 6.31 :/, was added in mIRC 6.17 smile


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Wims #209171 05/02/09 08:25 PM
Joined: Feb 2007
Posts: 234
M
Fjord artisan
Offline
Fjord artisan
M
Joined: Feb 2007
Posts: 234
some one dedicated can port this javascript code to mirc script (it CAN be done!)

http://www.webtoolkit.info/javascript-utf8.html

mostly you only need this, turn it into an alias.

Code:
    // public method for url decoding
    decode : function (utftext) {
        var string = "";
        var i = 0;
        var c = c1 = c2 = 0;

        while ( i < utftext.length ) {

            c = utftext.charCodeAt(i);

            if (c < 128) {
                string += String.fromCharCode(c);
                i++;
            }
            else if((c > 191) && (c < 224)) {
                c2 = utftext.charCodeAt(i+1);
                string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
                i += 2;
            }
            else {
                c2 = utftext.charCodeAt(i+1);
                c3 = utftext.charCodeAt(i+2);
                string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
                i += 3;
            }

        }

        return string;
    }


this doesnt work, but its a start for someone who wants to fix it:
//echo -a $utf8decode(aáéíóúe)
returns:
7 9 2 2 2 2 2
Code:
alias utf8decode {
  bset -t &utftext 1 $1-
  var %string
  var %i = 0
  var %c = c1 
  var %c2 = 0

  while (%i < $bvar(&utftext,0)) {
    var %c = $asc($bvar(&utftext, %i))
    if (%c < 128) {
      %string = %string $chr(%c)
      inc %i
    }
    elseif ((%c > 191) && (%c < 224)) {
      %c2 = $asc($bvar(&utftext, %i+1))
      %string = %string $chr(((%c & 31) << 6) | (%c2 & 63))
      %i = $calc(%i + 2)
    }
    else {
      %c2 = $asc($bvar(&utftext, %i+1))
      %c3 = $asc($bvar(&utftext, %i+2))
      %string = %string $chr(((%c & 15) << 12) | ((%c2 & 63) << 6) | (%c3 & 63))
      %i = $calc(%i + 3)
    }
  }
  return %string
}



these will come in handy:
http://www.w3schools.com/jsref/jsref_fromCharCode.asp
http://www.w3schools.com/jsref/jsref_charCodeAt.asp

http://jennifermadden.com/javascript/operators.html
a += b is the same as a = a + b

that is a good start i think.

Last edited by MTec007; 05/02/09 08:35 PM.

Link Copied to Clipboard