Simone,
You are using a byte array to read your data. When converting a byte
array to a String, you should specify encoding.
My guess is it's Western European, so you'd do:
new String(someByteArray, "iso-8859-1")
Also your code tries to convert the entire byte array to String and then
extracts a substring. You really should not pass garbage (unread) bytes
at the end of the array to the String constructor. Convert just the
bytes that actually came from the file:
byte[] byte_buffer = new byte[some length here, sufficient for read to succeed];
int actual_read = instrStr.read(byte_buffer);
String s = new String(byte_buffer, 0, actual_read, "iso-8859-1");
-- Kostya
10.09.2010 19:48, Simone пишет:
I fill a TextView like this:
TextView instructions=(TextView)
findViewById(R.id.batteryInstructionsText);
try {
InputStream instrStr=res.openRawResource(R.raw.instructionsfile);
byte [] text=new byte[580];
int i=instrStr.read(text);
instructions.setText(new String(text).substring(0, i));
} catch (Exception e) {
instructions.setText(res.getString(R.string.instrerror));
}
The problem is that instead of accented letters (à, è, é, ù, ò..) a
question mark is displayed.
How can I solve this?
Simone
--
Kostya Vasilyev -- WiFi Manager + pretty widget -- http://kmansoft.wordpress.com
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en