Send text in utf8 in a trigger

Posted by Gunner on Tue 28 May 2024 08:58 PM — 2 posts, 5,925 views.

Argentina #0
Hello,
I'm playing a mud whose encoding is utf8.
I have checked this checkbox in the output settings "UTF-8 (Unicode)".
Also, I use this plugin to send text in utf8:
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>

<muclient>
<plugin
name="Translate_ISO_TO_UTF8"
author="lostsnow"
id="b5d6c2e22177e7a13b081a29"
language="Lua"
purpose="Translate sent text GBK into UTF-8"
date_written="2018-07-02 13:19:26"
requires="4.25"
version="1.0"
>
</plugin>

<!-- Script -->
<script>
<![CDATA[
function OnPluginSend (sText)
assert (package.loadlib ("luaiconv.dll", "luaopen_iconv")) ()
local cd = iconv.open("UTF-8", "ISO-8859-1")
local nstr, err = cd:iconv(sText)
Send ((nstr))
return false
end -- OnPluginSend
]]>
</script>

</muclient>

But when I create a trigger and use the Note() function to send text with special characters, it looks bad:
<triggers>
<trigger
enabled="y"
group="Quest"
match="El Dios Probador te cuenta 'Busca * en el area de *!'"
omit_from_log="y"
omit_from_output="y"
send_to="14"
sequence="99"
>
<send>Note("Busca el objeto en %1, área %2")
Execute("history_add questman=Busca el objeto en %1, área %2")</send>
</trigger>
</triggers>

But when the trigger is triggered, the accent on the á of the word área is not displayed correctly.
How can I make the text I sent through the Note() function be sent in utf8?
thanks
Australia Forum Administrator #1
It appears that Note (or print) does not expect UTF8 characters.

You can try:


Note (utils.utf8convert ("Busca el objeto en %1, área %2"))


I doubt that would work for Unicode characters with a code number > 255.

For those characters (if you have them) you might need to convert them like this:


Note (utils.utf8encode (282))  -- Ě


This is a bit of a work-around, I'll see if we can improve the way Note works.