Home › HTML Tutorial › Charsets and URL encoding
Charsets and URL encoding
Text encoding in files and links.
Declare <meta charset='utf-8'> so every language displays correctly. URLs can only hold safe characters, so others become % codes: a space is %20.
Example code
<script>
const s='a b&c/ΓΌ';
document.write('<p>'+encodeURIComponent(s)+'</p>');
document.write('<p>'+decodeURIComponent('a%20b')+'</p>');
</script>'