[Home] [Downloads] [Search] [Help/forum]

Gammon Forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Lua
. . -> [Subject]  Trying to convert plugin to Lua need help with URI encoding
Home  |  Users  |  Search  |  FAQ
Register forum user name
Forgotten password?
(New message)
Subject: Trying to convert plugin to Lua need help with URI encoding
Your forum user name.
Register forum user name
Your forum password.
Forgotten password?
Message to be posted (in English, please)
Maximum of 6000 characters. Text only please, no HTML.
Forum codes:
Check this if your message uses 'forum codes' or templates (auto-detected for new posts).
Forum codes Templates

Save this message ...

Subject review (reverse sequence)

Posted by Nick Gammon   Australia  (19,673 posts)  [Biography] bio   Forum Administrator
Date Sat 06 Sep 2008 03:35 AM (UTC)  quote  ]


There are a few other pages that describe connecting to the Internet with Lua using luasocket.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] bio   Moderator
Date Fri 05 Sep 2008 04:44 PM (UTC)  quote  ]
You could probably lift this function from one of the various Lua web modules, like Kepler (www.keplerproject.org) -- that would be likely to be quite tested and handle the various subtle issues that this kind of thing runs into. Furthermore, the license is very liberal (MIT) so you wouldn't have issues with that.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

[Go to top] top

Posted by Beale   (35 posts)  [Biography] bio
Date Fri 05 Sep 2008 02:50 PM (UTC)  quote  ]
No - the Lua libraries are somewhat sparse for various reasons, while Javascripts are somewhat large for various other reasons.

With the usefulness that is the added utils functions in MUSHClient, though, you can throw together something like this fairly easily:

-- Modes: 1 - escape, 2 - encodeURI, 3 - encodeURIComponent
function escapeURIs(sIn, mode)
  find=string.find -- Shortcut to avoid repeat lookups

  -- Characters to omit for escape, encodeURI 
  --   and encodeURIcomponent respectively
  searchStrings={[[@*/+]], [[~!@#$&*()=:/,;?+']], [[~!*()']]}
  search = searchStrings[mode]

  -- Iterate over each character in the string
  for char in string.gmatch(sIn, ".") do

    -- Check character against omissions and convert
    if find(search, char, 1, true) == nil then 

  return sOut

This should serve your needs, but be aware it's not comprehensively tested. (I checked it against a few strings in each mode, but that's it.)
[Go to top] top

Posted by Cage_fire_2000   USA  (119 posts)  [Biography] bio
Date Fri 05 Sep 2008 02:09 PM (UTC)  quote  ]

Amended on Fri 05 Sep 2008 02:10 PM (UTC) by Cage_fire_2000

Hi, I have a plugin which allows you to launch web searches from MUSHclient, right now it's written in JScript, and I use encodeURIComponent() to encode the search parameters, is there anything equivilant in Lua? I'd rather not code it from scratch since I'm not that familiar with Lua yet, and it just seems like a lot of work for little benefit.

Edit: Oh, and before I forget I'd also need something like encodeURI().
[Go to top] top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


It is now over 60 days since the last post. This thread is closed.   [New subject]  Start a new subject   [Refresh] Refresh page

Go to topic:           Search the forum

[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.


Written by Nick Gammon - 5K

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( http://www.gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Web site powered by FutureQuest.Net]