Nick Gammon said:
Quote:
And also, how should I debug such issues? I am not sure what are the line 4 and column 171 referring to.
I am no Perl expert, but I expect that is the line and column in the script.
Yes, it is the line and column of the script.
It was confusing me because it didn't report the exact column of the problematic characters.
Anyway, the error reporting is not a real issue, but the parameter transferring with non-English parameters is. I still have no idea on what exactly happened there.
After some testing, I guess the problem is not either in Perlscript or Mushclient, but should be in the parameter passing between them.
In the mud I am playing, the output uses Chinese character set, say "gb2312". But from the syntax error messages (something like \x8C), it seems that those characters are encoded as utf8 at somewhere, but perl doesn't regard it as utf8.
I tried to decode/encode the characters to force them to be encoded as "gb2312" before passing them to a mushclient function, something like below:
my $var = encode("gb2312", decode("gb2312", "%1"));
$world->FUNCTION("$var");
Sometime it works, but not always.
Also, there are some other interesting observations.
1. Normally, passing a parameter in Chinese to $world->Note("%1") has no problem, but passing it to $world->SetVariable("var", "%1") have problems.
2. Inserting some empty lines around the problematic lines could solve the problem, but not always.
For example, assuming %1 is a string in English, while %2 is a string in Chinese.
1) $world->SetVariable("var1", "%1");
$world->SetVariable("var2", "%2");
This kind of trigger normally has problem when %2 is Chinese characters.
2) But if I insert some empty lines, like:
$world->SetVariable("var1", "%1");
$world->SetVariable("var2", "%2");
Exact same scripts, but just couple more new lines will make it work!
Any thoughts?
Also, would you please provide some more details on how mushclient running a trigger with Perlscript (I mean the triggers defined in GUI or MCL), especially the parameter passing part? Is there any encoding/decoding steps in mushclient when calling perl interpreter?
Thank you very much!