ahmed baseet schrieb:
> I first converted the whole string to
> byte array and then used that byte array to create a new utf-8 encoded sting
> like this,

I'm not sure that this is required at all. Java strings have the same
representation internally no matter what they were created from. Thus,
the code snipped you posted is wrong.

> // Encode in Unicode UTF-8
>                 byte [] utfEncodeByteArray = textOnly.getBytes();
>                 String utfString = new String(utfEncodeByteArray,
> Charset.forName("UTF-8"));

Especially the expression "textOnly.getBytes()" is wrong. It converts
the String to a set of bytes using the JVM's default encoding. Then you
convert the bytes back to a string using UTF-8 encoding.

You carefully have to check *how* the string "textOnly" is created in
the first place. That's where you UTF-8 issues might come from.

-Gunnar

-- 
Gunnar Wagenknecht
gun...@wagenknecht.org
http://wagenknecht.org/

Reply via email to