mIRC Homepage

How to use $utfdecode the right way?

Posted By: NiGHtOwL

How to use $utfdecode the right way? - 20/12/08 08:29 AM

I am having a script showing things the way I like it.

For example: Nickname shows like this <<NiGHtOwL>>

Now, since mIRC is able to dosplay UTF8, it does, but without my short script. When I am loading my script, then UTF8 won't be shown. That means that others who write in UTF8 in the Channel and as soon they are writing german vowels like AE UE OE (forum doesn't display it either) it will be displayed like A 1/3 or similar.

I tried to fix that myself by adding $utfdecode to my script.
This works so far, but I am receiving error messages:

Invalid parameters: $utfdecode

So something must be wrong. I looked up a lot of things but utfdecode and utfencode aren't documented yet. Nothing in the help file as well. I am using the newest version of mIRC 6.35

Here is the code I changed:

;B e f o r e

on ^*:TEXT:*:*:{
  var %nick = $iif($chan,$left($remove($nick($chan,$nick).pnick,$nick),1) $+ $nick,$nick)
  var %window = $iif($chan,$chan,$nick)
  echo -tmi2 %window 00 $+ %nick $+ 0 $1-

;A f t e r
on ^*:TEXT:*:*:{
  var %nick = $iif($chan,$left($remove($nick($chan,$nick).pnick,$nick),1) $+ $nick,$nick)
  var %window = $iif($chan,$chan,$nick)
  echo -tmi2 %window 00 $+ %nick $+ 0 $utfdecode($1-)

When someone writes ae oe ue (with the dots above) now, I am able to read it but the Nickname is no longer displayed the way I wanted it to be.

Can someone tell me what and how to do it right and no error messages turn up?

Thanks in advance
Posted By: 5618

Re: How to use $utfdecode the right way? - 20/12/08 04:46 PM

Just a note.

From my own testing just now it seem that the error occurs when you try to decode "strange" character that are not UTF-8 encoded to start with.

For this exercise let's call the ascii chars Alt+131 Alt+132 Alt+133 "[chars]"
//echo -a [chars]

This will (should?) give you: a[accent circonflex] a[umlaut] a[accent grave].
Now copy these chars and paste them in the editbox. You'll see they appear as your input [chars]

//echo -a $utfencode([chars])

Copy them again and you'll see something completely else.

The $utfencoded chars you'll be able to throw into a $utfdecode identifier and decode them back to [chars]. However, the non-encoded ascii chars will give you an 'invalid parameters' error.
It works fine if you add any standard chars below ascii value 127 (Alt+127, you'll notice, is the last char when you paste utfencoded text).

So apparently any char that's not found in the ascii table between 1 and 127 and not UTF-8 encoded will cause your script to error out. There *could* be parameters to circumvent this, but since the identifier is not documented...

For what it's worth. :P
Posted By: Horstl

Re: How to use $utfdecode the right way? - 27/12/08 03:04 PM

Making use of another *undocumentated* identifier (part of the changelog, but not yet in the helpfile):

versions.txt (17/02/2006 - mIRC v6.17, #48)
Added $isutf(text) identifier, returns UTF-8 status of text, where 0 = not UTF-8 (contains invalid UTF-8 sequences), 1 = seems to be plain text, 2 = seems to contain valid UTF-8.

Try replacing your:
$iif(($isutf($1-) == 2),$utfdecode($1-),$1-)

© 2020 mIRC Discussion Forums