0

I'm trying to unescape this string "Selby%2C%20SD" so the result would be "Selby, SD" (I assume) but can't find the way.

I've tried

StringEscapeUtils.unescapeHtml4("Selby%2C%20SD")

but the result is the same string. I've also tried StringEscapeUtils.unescapeHtml but didn't work either. What am I doing wrong?

Thanks.

StackFlowed
  • 6,604
  • 1
  • 28
  • 44
Nick L Scott
  • 673
  • 1
  • 8
  • 20

1 Answers1

3

You should use URLDecoder in java.net.URLDecoder;

import java.net.URLDecoder;

public class MainClass {

    public static void main(String [] args) {
        String tempStr = "Selby%2C%20SD";
        System.out.println(URLDecoder.decode(tempStr, "UTF-8"));
    }
}

Output:

Selby, SD
StackFlowed
  • 6,604
  • 1
  • 28
  • 44