The code has to create a simple csv file but one of the column headers has a µ character and the output to the file is µ.I have tried UTF-16, UTF-16LE, UTF-16BE, ASCII, and Hex for example substituting the char with “u00B5”. The UTF-16 encoding writes the char correctly but places 2 different garbage chars at the beginning of the line. I have been googling and working on this but can’t seem to get it to work. Hopefully, someone can see what I am missing?
Current code:
OutputStreamWriter fw = new OutputStreamWriter(new FileOutputStream(file), StandardCharsets.UTF_8);
int Q = 181;
char mu = (char) Q;
String sLine = "FileName,WellId,Sample Description,From [bp],To [bp],Average Size [bp],Conc. [pg/" + "u00B5" + "l],Region Molarity [pmol/l],% of Total,Region Comment,Dilution Multiplier" + newLine;
System.out.println(sLine);
fw.write(sLine);
Current output is the attached image.
Output
Manual excel file creation:
Manual excel creation
20