The Eula module from code.google.com works great but it doesn't display Unicode characters (e.g. ©) for some reason.
I know that AlertDialogs are perfectly capable of displaying Unicode characters, because I do so in other dialogs in my app.
The only difference I have been able to find between Eula's dialog and others is that the Eula.java dialog gets its string from a text file in the assets folder:
private static CharSequence readEula(Activity activity) {
BufferedReader in = null;
try {
in = new BufferedReader(new InputStreamReader(activity.getAssets().open(ASSET_EULA)));
String line;
StringBuilder buffer = new StringBuilder();
while ((line = in.readLine()) != null)
buffer.append(line).append('\n');
return buffer;
}
catch (IOException e) {
return "";
}
finally {
closeStream(in);
}
}
That text file displays all Unicode characters in Notepad++, so I can only suspect InputStreamReader
, BufferedReader
or StringBuilder
doing something to the string on its way from the assets file to the AlertDialog.
How can I make Eula.java display Unicode?
Give InputStreamReader
the encoding of the source data; this class transcodes data to UTF-16 character data.