function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Shweta GargShweta Garg 

Problem in displaying Japanese or bold character in the CSV file inside ZIP file

Hello,
I have a requirement to send ZIP file containing multiple CSV files.I am using Zippes library to cerate ZIP file in apex.
Here is the code.
Blob exceldata;
Zippex sampleZip = new Zippex();
sampleZip.addFile('rooms.csv', exceldata, null);

Blob zipBlob = sampleZip.getZipArchive();

Document newdoc = new Document();               
newdoc.Name = 'Roomtest'+'.zip';
newdoc.FolderId = UserInfo.getUserId();
newdoc.Body = zipBlob;
newdoc.ContentType = 'application/x-zip-compressed;charset=UTF-8';
insert newdoc;
This rooms.csv file contains some bold charcters and Japanese charcters .But When I downloaded the document ,bold and  japanese charcters are not showing properly.

Is there any way to define the file type of CSV file inside ZIP file ?How can we display japanese or bold charcaters properly in th CSV file inside  ZIP ?Please help.

Thanks in advance.



 
karthikeyan perumalkarthikeyan perumal
Hello, 

you need to save your CSV file with UniCode(UTF-8) format.  from your code i think  your creating ZIP file and defining type as zip and encoding that ZIP file not for that CSV file already there in the ZIP file. 

if CSV file manually created try below method to encode CSV and add it to ZIP folder. 

While do the save as option for CSV, 

User-added image

User-added image

Hope this will helps you to keep the CSV document in original format. 

Thanks
karthik

 
Shweta GargShweta Garg
Hello Karthik,

Thank you so much for  the  reply.
But that is problem .I wanted to define the file type(text/html;charset=UTF-8) for CSV file which I am adding  in ZIP file.But there is no option to define File type in this method(sampleZip.addFile('rooms.csv', exceldata, null);).

Here I am using ZIPPEX library to cerate ZIP file.
https://github.com/pdalcol/Zippex

Regards,
Shweta
karthikeyan perumalkarthikeyan perumal
Hello, 

Try below code,   i hope it will work, just give a try..   i just added  exceldata.toString().
 
Blob exceldata;
Zippex sampleZip = new Zippex();
sampleZip.addFile('rooms.csv', exceldata.toString(), null);

Blob zipBlob = sampleZip.getZipArchive();

Document newdoc = new Document();               
newdoc.Name = 'Roomtest'+'.zip';
newdoc.FolderId = UserInfo.getUserId();
newdoc.Body = zipBlob;
newdoc.ContentType = 'application/x-zip-compressed;charset=UTF-8';
insert newdoc;

i refered below link 

https://salesforce.stackexchange.com/questions/12336/upload-csv-in-different-encoding-than-utf-8

Thanks
karthik
​​​​​​​
Shweta GargShweta Garg
Hello Karthik,

Here is the syntax for addfile method in the  ZIPPEX library.
public void addFile(String fileName, Blob fileData, String crc32)

File data must be in Blob.It will not accept String .
Morever,if I open the ZIP file using ZIP Extrcator of google drive then it is working fine.

Thanks,
Shweta