extended ascii being munged in Lua plugins?

Posted by Fiendish on Mon 07 Apr 2014 05:00 AM — 8 posts, 22,726 views.

USA Global Moderator #0
On my input line \\\print(string.gsub("───", "─","-")) prints the expected "---".
But if I then put that line in a plugin it fails to work.

If I introduce an error on that line, it spits out

Quote:
63*: text = string.gsubd(text, "─","-")


Is the plugin processor interfering with my strings?
Australia Forum Administrator #1
I can't reproduce that. Using this plugin:


<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>

<muclient>
<plugin
   name="test_extended_ascii"
   author="Nick Gammon"
   id="b0ba651e71e0c226a60ae8f2"
   language="Lua"
   purpose="Test for Fiendish"
   date_written="2014-04-08 09:43:19"
   requires="4.90"
   version="1.0"
   >

</plugin>

<script>

function OnPluginInstall ()
print(string.gsub("───", "─","-"))
end -- function

</script>

</muclient>


I see:


--- 3
Reinstalled plugin test_extended_ascii (b0ba651e71e0c226a60ae8f2)


Changing "gsub" to "gsubd" I see:


Run-time error
Plugin: test_extended_ascii (called from world: smaug2)
Function/Sub: OnPluginInstall called by Plugin test_extended_ascii
Reason: Executing plugin test_extended_ascii sub OnPluginInstall
[string "Plugin"]:2: attempt to call field 'gsubd' (a nil value)
stack traceback:
        [string "Plugin"]:2: in function <[string "Plugin"]:1>
Error context in script:
   1 : function OnPluginInstall ()
   2*: print(string.gsubd("───", "─","-"))
   3 : end -- function
Added plugin C:\Program Files\MUSHclient\worlds\plugins\test_extended_ascii.xml


Isn't that what you expect?
USA Global Moderator #2
What you have is exactly what I expect. What I have is not.
Interesting.
Australia Forum Administrator #3
Try it with the supplied Lua DLL instead of the JIT one. Also try my exact plugin, see if that makes a difference.

I had UTF-8 turned off in the output window. If I turn it on the output window immediately refreshes to read:


Error context in script:
   1 : function OnPluginInstall ()
   2*: print(string.gsubd("───", "─","-"))
   3 : end -- function
USA Global Moderator #4
Nick Gammon said:
Try it with the supplied Lua DLL instead of the JIT one.
Eh. But it works fine for me from the command line with the same dll?

Quote:
Also try my exact plugin, see if that makes a difference.

And your plugin works fine for me too. Uh...
Amended on Wed 09 Apr 2014 01:12 AM by Fiendish
Australia Forum Administrator #5
Hmmm must be more to this than meets the eye. ;)
USA Global Moderator #6
Change your plugin to first print the original line. With UTF8 disabled I see (plus a few boxes that don't print here)
Quote:

───

Which is again not the same as what I get from the input line. :/

At least I can get it to work if I convert tohex/fromhex and gsub hex codes instead of extended ascii.
Amended on Sat 12 Apr 2014 05:22 PM by Fiendish
Australia Forum Administrator #7
You mean like this?


function OnPluginInstall ()
print ("───")
end -- function


I see:


───


Same as executing it from the command line.