Message info From:Dirk Vranckaert Subject:[android-developers] Writing files in UTF-8 Date:Thu, 29 Mar 2012 00:25:48 -0700 (PDT)

In my application users can export their data (or a subset of it) to a CSV file (to be used in Excel or any other spreadsheet app).
However some of my users are reporting that if they export some that contains non-western characters (like chinese or hebrew writings) the text is not correctly in the export.

When I try this myself I indeed see that the text is not correct. Here is the code that writes the content to the file (UTF-8 encoded).

Writer out = null;
try {
    out = new BufferedWriter(new OutputStreamWriter(
new FileOutputStream(file), "UTF-8"
} catch (UnsupportedEncodingException e) {
    Log.e(LOG_TAG, "The encoding is not supported!", e);
} catch (FileNotFoundException e) {
    Log.e(LOG_TAG, "The file is not found", e);
} catch (IOException e) {
    Log.e(LOG_TAG, "Exception occurred during export...", e);
} finally {
    if (out != null) {
try {
} catch (IOException e) {
    Log.e(LOG_TAG, "Could not close the writer", e);

Is there anything else that I can do to optimize my code to support those languages?


Dirk Vranckaert

You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to
To unsubscribe from this group, send email to
For more options, visit this group at