Chinese trigger not loaded

Posted by Flow on Wed 13 Jun 2012 04:10 AM — 10 posts, 31,268 views.

#0
Hi everyone,

I am new to Mushclient and I have been investigating one issues regarding chinese trigger using regex.

The mud is using Big5 and I cannot check the utf-8 box.
When the triggers contain some special chinese words(eg. "架","跋", "崙"), they are not loaded when I open the world.

It gave a error message saying "Failed: missing terminating ] for character class"

I tried to use some encoder to check those words, all of them contain "%5B" which can be decoded to "[".

I think that's the cause of the problem.

Is there any workarounds to make the regex treating the whole sentence as one string but to check it byte by byte?

Please help.

Thanks
Australia Forum Administrator #1
What is Big5?

Quote:

I cannot check the utf-8 box.


Why not?
#2
Hi Nick,

Big5 is an encoding for traditional chinese..
Because the mud is using big5, the words will be corrupted if I check the utf-8 box..

The second byte of the chinese character was translated to "[" which make the triggers failed.

Thanks.

Australia Forum Administrator #3
I see. Well I suggest making a plugin that converts incoming packets from Big5 to UTF8, then you can check the UTF8 box and the trigger should work.
Australia Forum Administrator #4
I don't know enough about Big5 to be much more specific, but check out this:

http://www.gammon.com.au/scripts/doc.php?general=plugin_callbacks

In particular:


OnPluginPacketReceived

You should be able to do a simple Lua global replace where it converts Big5 to UTF8 from a simple table.
#5
Nick,

Thank you very much.

I will try that out first.

by the way, is there any way to make pcre work better on chinese?
Australia Forum Administrator #6
Sort of an example here:

http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=8747

You basically want to match on "." (anything) and then look up each character in a table and convert it to UTF8.
Australia Forum Administrator #7
Flow said:

by the way, is there any way to make pcre work better on chinese?


Turn UTF-8 on, it can't know that the characters are not the usual meanings.

Although for triggers it *might* just work to put an underscore before it.

For example, instead of matching on 架 match on \架
#8
Nick Gammon said:

For example, instead of matching on 架 match on \架


this does not work..
Because chinese words have 2 bytes..
the problem is that the last byte become a special character..
there is no way to insert \ in between those 2 bytes..

I am looking for a way to group the words and then ignore all special characters inside the group..

seems no such method.
#9
Finally got one way to solve this...
Quote the word by /Q.../E ..
this will enclose the characters as literal and ignore all syntax...

Thanks all...