/// Encodes a text string as a valid Uniform Resource Identifier (URI)

var hMainWnd=AkelPad.GetMainWnd();
var nSelStart;
var nSelEnd;
var pSelText;
var pResult;

if (hMainWnd)
{
  nSelStart=AkelPad.GetSelStart();
  nSelEnd=AkelPad.GetSelEnd();
  if (nSelStart == nSelEnd)
    AkelPad.SetSel(0, -1);

  pSelText=AkelPad.GetSelText();
  pResult=encodeURI(pSelText)
  AkelPad.ReplaceSel(pResult);

  if (nSelStart == nSelEnd)
    AkelPad.SetSel(0, -1);
  else
    AkelPad.SetSel(nSelStart, nSelStart + pResult.length);
}
