- 1). Open your HTML file in an editor such as Microsoft Windows Notepad.
- 2). Insert a script tag in the head section of your HTML file by adding the code:
<script type="text/javascript"> - 3). Declare a JavaScript variable and assign it a text value by adding the code:
var uri = "http://myserver.com/page.asp?type=måle&id=11"; - 4). Encode a URI component with the "encodeURIComponent" function by adding the code:
var uri_encode = encodeURIComponent(uri);
The function encodes characters with their UTF-8 encoding. The "uri_encode" variable now has a value of:
http%3A%2F%2Fmyserver.com%2Fpage.asp%3Ftype%3Dm%A5le%26id%3D11 - 5). Store the decoded component of a URI in a variable and end the script by adding the following code:
uri_decode = decodeURIComponent(uri_encode));
</script>
The variable has the value of the original string:
http://myserver.com/page.asp?type=måle&id=11 - 6). Save the HTML file and load it on your server to convert the UTF-8 text.
SHARE