1. Add the JSP writing file to the BOM header.
Note: In the following situations, Chinese garbled characters are not added without the BOM header. It just shows how to add the BOM header to the JSP output file.
<% Response. setcontenttype ("application/CSV"); response. setheader ("content-disposition", "attachment; filename = \" exporteddata.csv "); string Ss =" Chinese test "; out. write (0xef); out. write (0xbb); out. write (0xbf); out. println (SS); out. flush (); %>
Supplement:
Out. Write () is a byte output stream method.
Out. Print () is the method of character output stream
2. Add the C write file to the BOM Header
File * file = NULL; string sfilename = "test.csv"; char utfbomheader [4]; utfbomheader [0] = '\ 0'; utfbomheader [0] = 0xef; utfbomheader [1] = 0xbb; utfbomheader [2] = 0xbf; utfbomheader [3] = '\ 0'; file = fopen (sfilename, "A +"); fprintf (file, "% s \ n", utfbomheader); fflush (File); fclose (File );