This example will show using the functions for encoding and decoding URLs. This is also known as Percent-encoding and is basically escaping a string for use on the URL line.
This is needed when you build links to other pages and other places where you need to escape URL data
This example will use WS_URLEncode(), WS_URLDecode(), and WS_URLDecodeInPlace()
In this example file server only serves simple page showing encoded and decoded strings.
This goes at the top and defines the 3 standard pages we serve.
The page starts off by writing out the string "100% of chars are <i>escapable</i>".
The WS_URLEncode() function is called to encode the string as a URL string. The output string will be placed in the buffer EncodedStr. This buffer should be 3 times the size of the source string because the string can be made up to 3 times bigger. In this case the string is 34 bytes and the output buffer is 200 bytes long. The last argument to WS_URLEncode() is the size of the output buffer
The next thing the example does is decode the string we just encoded using the WS_URLDecode() function. This will take a URL encoded string and convert it back to a normal string. Again The output string will be stored in DecodedStr The last argument to WS_URLDecode() is the size of the output buffer
Finally the WS_URLDecodeInPlace() function is used to decode the string again. This time the input buffer is used to store the new string. This works because the decoded string will always be shorter than the source string.