Codek
Codek

Reputation: 5164

Convert unicode representations on incoming string to UTF-8?

I'm reading some data that has already been converted to html style υ code.

I now need to convert this back to UTF-8 characters for viewing. Unfortunately I can't use a browser to view the string.

I've read around about conversion in java and it seems if you have a string of \uxxxx then the compiler will convert for you; However that wont work of course because I want to read in dynamic strings.

So can this be done?

Many thanks! Dan

Upvotes: 2

Views: 3056

Answers (3)

Michael Borgwardt
Michael Borgwardt

Reputation: 346270

converted to html style υ code.

Which of those? \uXXXX is a Java convention and has nothing to do with HTML. HTML entities look like ¯

Upvotes: 0

Alnitak
Alnitak

Reputation: 339816

You need to use:

String StringEscapeUtils.unescapeJava(String str)

from the Apache Commons Library.

It will find \uxxxx sequences in the input string and convert them to a normal Java String.

Upvotes: 4

ksuralta
ksuralta

Reputation: 17106

native2ascii

Use the "-reverse" option.

Upvotes: 0

Related Questions