There are 2 types of encoding pertinent to your problem. HTML escape characters, and URL escape chars.
When you have a character in an HTML page, you use the HTML escape characters. eg
w = w
But you cannot use those characters in a URL - &
and #
have special meanings in URLs. So you have to encode again - this time using URL escape characters.
# = %23
& = %26
; = %3B
So your string, ('w') fit to be put into a URL, would be:
%23%26119%3B
and your entire query string:
?text=%23%26119%3B&type=htmldecode&format=text
the aforementioned PHP urlencode() does this.
The snippet:
<?php echo urlencode("w"); ?>
outputs
%26%23119%3B