views:

22

answers:

1

Hello,

i am trying to write a CSV file include arabic data using java as

PrintWriter out = new PrintWriter("file.csv", "UTF8");

and the when i open the file in Linux machine , the Arabic displayed fine but it doesn't work with windows machine.

and when set encoding to be "Cp1256" as

 PrintWriter out = new PrintWriter("file.csv", "Cp1256");

The Arabic is displayed fine with windows xp & window7 but fails with linux and windows vista.

So what is the right encoding that make file works with all OSs ?

Thanks in Advance

Neveen

+1  A: 

The right way is to use a Unicode encoding such as UTF-8, as in your first example. Encodings like Windows-1256 are non-portable and obsolete; even Microsoft recommends against them.

Please specify where exactly (console, text editor…) you want to display your file. The Windows console has a few problems with Unicode related to fonts and encodings, but displaying the file in any GUI application should be fine on all modern (post–2000) OSes.

Philipp
I want to display the file into excel editor but the Arabic doesn't displayed fine with "UTF-8"Thanks
Neveen
I have little experience with Excel, but I guess it can deal with UTF-8 files. Maybe you have to specify the encoding when loading the file. Can you open the file in e.g. Notepad? — I think this has more of an Excel than a Java question; try to ask on SuperUser.
Philipp