I have a key(12345#678!9) which I need to encode on 2 applications, one C# one Java.
C#
var key = "12345#678!9";
var enc = HttpUtility.UrlEncode(key, Encoding.UTF8);
Console.WriteLine(enc);
The output here is 12345%23678!9
Java
var key = "12345#678!9";
var enc = java.net.URLEncoder.encode(key, StandardCharsets.UTF_8.toString);
System.out.println(enc)
The output here is 12345%23678%219
As you can see the two encoded values are different, the Java code is encoding the '!' as %21 where the C# code is not.
I cant change the key nor can I change the C# code.
So a solution will need to be on the Java side.
Is there a Java the equivalent of the C# method HttpUtility.UrlEncode?
Are they other options aside from java.net.URLEncoder.encode that I could use?
Thanks in advance