escaping spaces in URL

searchText = screen.GetText()
print "search text: "; searchText

m.UrlBase = “http://somewebserver.com/web/
m.Text = “/sample.php?text=”
rhttp = NewHttp(m.UrlBase + m.Text + searchText)
rsp = rhttp.Http.GetToString()

I’m posting as a GET to a webserver. searchText is the result of input from the roKeyboardScreen. If I have spaces or reserved characters in searchText, it will print to the debug console, but the http GET silently fails.

My webserver will certainly take something like this http://somewebserver/web/sample.php?text=1111 3333

Is there anything I can do in Brightscript to quote searchText to be passed?

“SolveLLC” wrote:
searchText = screen.GetText()
print "search text: "; searchText

m.UrlBase = “http://somewebserver.com/web/
m.Text = “/sample.php?text=”
rhttp = NewHttp(m.UrlBase + m.Text + searchText)
rsp = rhttp.Http.GetToString()

I’m posting as a GET to a webserver. searchText is the result of input from the roKeyboardScreen. If I have spaces or reserved characters in searchText, it will print to the debug console, but the http GET silently fails.

My webserver will certainly take something like this http://somewebserver/web/sample.php?text=1111 3333

Is there anything I can do in Brightscript to quote searchText to be passed?

Actaully, the webserver won’t, it just looks like it does. Browsers silently escape or urlencode (I always get the terms mixed up) anything in the address bar, so what your webserver actually sees is:

http://somewebserver/web/sample.php?text=1111%203333

If you can check the logs of the webserver, you should be able to confirm or refute this.

If it is the escaping that’s the problem, you want is to escape the parameter value, but not the parameter name or URL. Look at the Escape and Unescape methods for the roURLTransfer object.

You were right. I use Escape on the parameter and it is working now. Thanks!