gospodin
gospodin

Reputation: 1201

Convert french accents to percent encoding

I have a simple

String abc = "réunion";

I should convert this string into the URL percent encoding - so I need:

String abc = "r%c3%a9union";

Any simple solution for this?

Upvotes: 1

Views: 4148

Answers (2)

user256717
user256717

Reputation:

URLEncoder.encode("réunion", "UTF-8")

Upvotes: 3

zmilojko
zmilojko

Reputation: 2135

Try this class:

         java.net.URLEncoder

For example, for encoding as UTF:

     import java.net.URLEncoder; 
     .....
     String utf_encoded = URLEncoder.encode(url.toString(),"UTF-8");

Upvotes: 5

Related Questions