unicode - setting a UTF-8 in java and csv file -


i using code add persian words csv file via opencsv:

string[] entries="\u0645 \u062e\u062f\u0627".split("#"); try{     csvwriter writer=new csvwriter(new outputstreamwriter(new fileoutputstream("c:\\test.csv"), "utf-8"));      writer.writenext(entries);     writer.close(); } catch(ioexception ioe){     ioe.printstacktrace(); } 

when open resulting csv file, in excel, contains "ứỶờịỆ". other programs such notepad.exe don't have problem, of users using ms excel.

replacing opencsv supercsv not solve problem.

when typed persian characters csv file manually, don't have problems.

unfortunately, csv ad hoc format no metadata , no real standard mandate flexible encoding. long use csv, can't reliably use characters outside of ascii.

your alternatives:

  • write xml (which have encoding metadata if right) , have users import xml excel.
  • use apache poi create actual excel documents.

Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

aspxgridview - Devexpress grid - header filter does not work if column is initially hidden -

c# - How to execute a particular part of code asynchronously in a class -