0

i work on a project of contacts i copy all the contacts and write them to csv file and then i upload them to firebase .

when i open this file (in any device) , i see that the contacts that writed with hebrew letters look weird.

this how its look : enter image description here

this is my code :

  public void generateNoteOnSD(Context context, String sFileName, String sBody) throws Exception {
    try {
        File root = new File(Environment.getExternalStorageDirectory(), "ProjectContacts");
        if (!root.exists()) {
            root.mkdirs();
        }
        File gpxfile = new File(root, sFileName);
        FileWriter writer = new FileWriter(gpxfile);
        OutputStreamWriter writer =new FileWriter(gpxfile);
        writer.append(sBody);//
        writer.flush();
        writer.close();
        Toast.makeText(context, "Saved", Toast.LENGTH_SHORT).show();
        //Toast.makeText(context, "Start upload", Toast.LENGTH_LONG).show();
        //UploadCsvFile(gpxfile);

    } catch (IOException e) {
        e.printStackTrace();
    }
}

sBody contain hebrew letters

i wish someone can help my . thanks.

2 Answers2

0

It's possible your CSV is not in UTF-8, so you might want to do as Alastair suggested and either open it up in something like Google Sheets or OpenOffice, or use a simple text editor like Notepad++ or Sublime Text 3 to find out what encoding your file is using, then import the CSV into Excel using the process outlined in this Stack Overflow post.

Of course, you could also add a UTF-8 BOM to your file, as mentioned in this post. Then Excel should automatically recognize the UTF-8 encoding and display any special characters properly.

Mihai Chelaru
  • 7,614
  • 14
  • 45
  • 51
0

Your data file is UTF-8. Excel does not read UTF-8 if you just "open" the file. What you should do is:

  • Open a NEW file in excel
  • Click on the top-left cell (or top-right if you excel is in Hebrew)
  • Click on the Data tab in the ribbon, and choose "From Text"
  • In the import Wizard:
    • Select "Delmited"
    • Make sure to select "UTF-8" Encoding ("File Origin")
    • Next
    • Select "Comma"
    • Finish

Encoding Selection Image

Nir Levy
  • 4,613
  • 2
  • 34
  • 47