The ENCODEURL function in Google Sheets is designed to encode a text string, ensuring it is suitable for use in a URL query. By converting special characters into a format that can be uniformly transferred over the web, this function helps maintain the integrity of data during transmission.
Syntax
ENCODEURL(text)
- text: The text string you wish to encode for URL usage.
Example #1
ENCODEURL("hello world!")
In this case, the function converts the string ‘hello world!’ into a URL-friendly format. The result would be ‘hello%20world%21’.
Example #2
ENCODEURL("search?q=Google Sheets")
This example encodes a typical query string, transforming it into ‘search%3Fq%3DGoogle%20Sheets’.
Example #3
ENCODEURL("&name=John Doe&age=30")
Here, the function encodes multiple parameters, resulting in ‘%26name%3DJohn%20Doe%26age%3D30’.
Error handling
- ERROR: Invalid input: This occurs if the input to the function is not a string or is left blank.
- ERROR: Too many arguments: This message can appear if more than one argument is supplied, as the function only accepts a single string.