I'm not sure exactly what you're asking, but I'll assume you're asking how to convert some characters from Unicode into an 8-bit character set. (e.g. ISO-8859-1 is the characterset for 'Western European' languages, like English).
I don't know of any way to automatically detect the relevant 8-bit charset, so I looked up one of your characters (on here http://unicode.org/charts/ ), and I can see that these characters are Bengali.
I think the equivalent 8-bit character set for Bengali is known as x-iscii-be
.
I don't have this installed on my system, so I couldn't do the conversion successfully.
EDIT: Java does not support the charset x-iscii-be
, but I'll leave the remainder of this answer for illustration purposes. See http://download.oracle.com/javase/7/docs/technotes/guides/intl/encoding.doc.html for a list of supported Charsets.
EDIT2: Android certainly doesn't guarantee support for this charset (the only 8-bit characterset it guarantees is ISO-8859-1). See: http://developer.android.com/reference/java/nio/charset/Charset.html .
*So, I think you should run some Charset-detecting code on a Bengali Android device - perhaps it supports this charset. Everything you need is in my code sample. *
In order for Java to convert your data in a different charset, all you need to do in Java is to check that the desired Charset is installed, and then specify the desired Charset when you convert the String into bytes.
The conversion itself would be extremely simple:
str.getBytes("x-iscii-be");
So, you see, the String itself is stored in a kind of 'normalised' form (i.e. the defaultCharset), and you can treat the getBytes(charsetName) as kind of 'alternative output format' for the String. Sorry - poor explanation!
In your situation, perhaps you just need to assign a Charset to the resultView, and the framework will work its magic for you ...
Here's some test code I put together to illustrate the point, and to check whether a given charset is supported on a system.
I have got this code to output the byte-arrays as 'hex' strings, so that you can see that the data is different after conversion.
import java.io.UnsupportedEncodingException;
import java.math.BigInteger;
import java.nio.charset.Charset;
import java.util.Map.Entry;
import java.util.SortedMap;
public class UnicodeTest {
public static void main(String[] args) throws UnsupportedEncodingException {
testWestern();
testBengali();
}
public static void testWestern() throws UnsupportedEncodingException {
String unicodeStr= "\u00c2"; //This is a capital A with an accent.;
String charsetName= "ISO-8859-1";
System.out.println("Input (outputted as default charset - normally unicode): "+unicodeStr);
attempt8bitCharsetConversion(unicodeStr, charsetName);
}
public static void testBengali() throws UnsupportedEncodingException {
String unicodeStr = "\u0986\u09AE\u09BF \u0995\u09BF\u0982\u09AC\u09A6\u09A8\u09CD\u09A4\u09BF\u09B0 \u0995\u09A5\u09BE \u09AC\u09B2\u099B\u09BF";
String charsetName= "x-iscii-be";
System.out.println(unicodeStr);
attempt8bitCharsetConversion(unicodeStr, charsetName);
}
public static void attempt8bitCharsetConversion(String input, String charsetName) throws UnsupportedEncodingException {
SortedMap<String, Charset> availableCharsets = Charset
.availableCharsets();
for (Entry<String, Charset> entry : availableCharsets.entrySet()) {
if (charsetName.equalsIgnoreCase(entry.getKey())) {
System.out.println("HEXED input : "+ toHex(input.getBytes(Charset.defaultCharset().name())));
System.out.println("HEXED output: "+ toHex(input.getBytes(entry.getKey())));
}
}
throw new UnsupportedEncodingException(charsetName+ " is not supported on this system");
}
public static String toHex(byte[] input) throws UnsupportedEncodingException {
return String.format("%x", new BigInteger(input));
}
}
See also here for more information on charset conversion: http://download.oracle.com/javase/tutorial/i18n/text/string.html
Charactersets are a tricky business, so please forgive my convoluted answer.
HTH