title: Opening CSV with UTF-8 BOM via Excel
body: <p>I create csv file with data by the means of java. And I faced the following well-known issue: the letters in Portuguese were displayed by the wrong way in Excel (when opening by double click). </p>
  
  <p>I solved this by UTF-16LE+BOM, but excel started to recognize tabs as columns separators instead of commas.</p>
  
  <p>So I looked up for another solution and saw many posts, in which people say that just adding UTF-8 BOM and writing file in UTF-8 will do the job for Excel 2007 and later. I tried the simpliest sample on my work computer and it failed. But when I tried this at my home computer it worked like a charm. </p>
  
  <p>Both computers have the same versions of java installed and operating system Windows 7.
  I am confused. Can anyone tell what can cause such a strange behaviour?</p>
  
  <p>You can see my simpliest sample below:</p>
  
  <pre><code>String filename = "D:/check/test_with_bom.csv";
          FileOutputStream fos = new FileOutputStream(filename);
          byte[] bom = new byte[] { (byte)0xEF, (byte)0xBB, (byte)0xBF }; 
          fos.write(bom);
          OutputStreamWriter osw = new OutputStreamWriter(fos , "UTF-8");
          PrintWriter printWriter = new PrintWriter(osw);
  
          printWriter.print("Hello,Olá,ão,ção");
          printWriter.close();
  </code></pre>