0

In Java, how can I convert a string containing unicode characters escaped to utf 8, e.g. from Rüppell's_Vulture to R%c3%bcppell's_Vulture

3
  • %c3% is not UTF-8 but html-escape Commented Jun 14, 2013 at 8:04
  • @Uwe: %c3 is not HTML-escaping, but URL-encoding. Commented Jun 14, 2013 at 11:08
  • user1774937: your question is very strange. You're clearly mixing some basic concepts. What exactly do you ultimately want to do with the escaped/encoded string? I.e. what exactly is the functional requirement for which you thought that this would possibly be the right solution? Only then, the right answer can be given. Commented Jun 14, 2013 at 11:10

2 Answers 2

1
String s = URLDecoder.decode("R%c3%bcppell's_Vulture", "UTF-8");
String s = URLEncoder.encode("Rüppell's_Vulture", "UTF-8");

With % it is an URL encoding.

Sign up to request clarification or add additional context in comments.

1 Comment

its doing the reverse, i.e. R%c3%bcppell to Rüppell
0

Copy it to byte array with getBytes("UTF-8). Like this:

byte[] utf = String.getBytes("UTF-8")

Do not know the way of dealing with it just with Strings (I believe they have fixed encoding).

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.