Documentation/Calc Functions/ENCODEURL

Function name:
ENCODEURL

Category:
Text

Summary:
Converts a text string that may contain a wide range of characters into another string that contains only characters that are permitted within an Internet URL (Uniform Resource Locator).

ENCODEURL encodes the unsafe and reserved characters appearing in the URL using percent-encoding.

ENCODEURL does not perform any checking of the input string's syntax and semantics – the function simply accepts any non-empty string and encodes any reserved and unsafe characters found. You can use this function to transform text with symbols of national alphabets (for example accented characters, non-ASCII alphabets, or Asian words) to a string of URL-standard symbols.

Syntax:
ENCODEURL(Text)

Returns:
Returns an encoded text string in which all original non-alphanumeric characters, except hyphen-minus (Unicode U+002D) and underscore (Unicode U+005F, also known as a low line), have been replaced with a percent sign followed by hexadecimal digits.

Arguments:
Text is a text string (in quotation marks), a number, or a reference to a cell containing one of those types, that specifies the string to be encoded.


 * If Text is an empty string, then ENCODEURL reports a #VALUE! error.

Additional details:
A URL is constructed from a limited set of characters belonging to the US-ASCII character set as defined in RFC 3986 - Uniform Resource Identifier (URI): Generic Syntax. In summary, these are: URL encoding is a method to convert other characters within URLs to a format that is understood by web browsers and web servers. Such characters are encoded using a percent sign (%) and a two-character hex value. URL encoding is also called percent-encoding since it uses the percent as an escape character.
 * The digits 0-9
 * The uppercase letters A-Z
 * The lowercase letters a-z
 * A few reserved characters

For more background information about URL encoding, see Wikipedia’s Percent-encoding page.

Example 1
where cell A1 contains the string "http://www.examples.com/search_for_examples?within=type2&sort_by=some_column_name". Here the function encodes the (ficticious) URL held as a string in cell A1, removing any unsafe and reserved characters, and transforming the URL to a percent-encoding.

The result is http%3A%2F%2Fwww%2Eexamples%2Ecom%2Fsearch_for_examples%3Fwithin%3Dtype2%26sort_by%3Dsome_column_name.

Example 2
. Here the function encodes a text string that is not a URL. The only characters in this string that need to be encoded are the two spaces.

The result is The%20Document%20Foundation.

Example 3
This example assumes the language of the cell is English.

. Here the function converts the numeric argument to a string, encoding the full stop.

The result is 345%2E678.

Example 4
where cell A1 contains the Russian text "автомобиль". Here the function encodes a text string that is not a URL and all characters in the string need to be encoded. "автомобиль" means car in Russia.

The result is %D0%B0%D0%B2%D1%82%D0%BE%D0%BC%D0%BE%D0%B1%D0%B8%D0%BB%D1%8C.

Example 5
where cell B1 contains the Japanese text "車". Here the function encodes a text string that is not a URL and the single character in the string needs to be encoded. "車" means car in Japanese.

The result is %E8%BB%8A.

Related LibreOffice functions:
FILTERXML

WEBSERVICE

ODF standard:
None.

Equivalent Excel functions:
ENCODEURL