API functions multi-byte safety between input and script

Posted by Fiendish on Mon 12 Feb 2018 10:25 PM — 8 posts, 22,811 views.

USA Global Moderator #0
If run from the input bar via script prefix,

print("¯")

shows nothing, which is unexpected

and
SetClipboard("¯")

grabs
¯

which is expected.



If run in a script (say, inside a plugin)
print("¯")

shows
¯

which is expected

and
SetClipboard("¯")

grabs
¯

which is unexpected


Is there something I should be doing to make those unexpected results look more like the expected ones?
Australia Forum Administrator #1
If I have UTF-8 turned off for the output window, and Dina as the font, then your first example works for me.


print("¯")


If I turn UTF-8 on then it isn't rendered.




As for the clipboard, are you running with UTF-8 enabled or not?
USA Global Moderator #2
Enabled. Otherwise I can't use ╔═══ for drawing maps in main output. Except that this is for a different plugin than the one that wants UTF8 output enabled, so I guess I need a solution that doesn't care.
Amended on Tue 13 Feb 2018 09:33 PM by Fiendish
USA Global Moderator #3
Side note, I'm pretty sure that only single byte characters matter for this, since Aardwolf doesn't actually support players sending utf8. So I guess maybe I need to convert everything to non-utf8 equivalent characters which should look identical.
Amended on Tue 13 Feb 2018 09:40 PM by Fiendish
USA Global Moderator #4
Hmm. There's no utils.utf8unconvert.
Amended on Tue 13 Feb 2018 10:50 PM by Fiendish
USA Global Moderator #5
I implemented my own utf8unconvert in Lua to replace low utf8 with extended ascii bytes, so I can now put "¯" into the clipboard from a script, but I'm not sure what to do about higher utf8 symbols like "╔"...
SetClipboard("╔════════════")

still produces
╔════════════
Australia Forum Administrator #6
Bear with me for a bit. We have had wild weather, the power failed, and now my Internet access is limited because the modem won't connect to the network.

I am writing this using a WiFi hotspot from my phone.
Australia Forum Administrator #7
I can't reproduce that. If I copy that SetClipboard line from your post and use it in the MUSHclient command window it appears like this:


SetClipboard("+------------")


And that copies to the clipboard OK.