URL encoding: Difference between revisions

Line 782:
 
=={{header|Java}}==
Java includes the ''URLEncoder'' and ''URLDecoder'' for this specific task.<br /><br />
The ''URLEncoder'' will convert a space to a '+' rather than '%20'.
<syntaxhighlight lang="java">
import java.net.URLEncoder;
Line 799 ⟶ 798:
/* rfc3986 and html5 */
case '-', '.', '_', '~', '*' -> encoded.append(character);
case ' ' -> encoded.append('+');
default -> {
if (alphanumeric(character))
Line 819:
</syntaxhighlight>
<pre>
http%3a%2f%2ffoo%20bar+bar%2f
</pre>
 
118

edits