You need to sign in to do that
Don't have an account?
XactiumBen
Character Encoding problems saving String in a Document record
I am trying to generate a CSV file using a Document record and a String I supply in the record's body. Here is how I'm doing it at the moment:
Document doc = new Document(); doc.Name = suppliedName; doc.FolderId = suppliedFolder; doc.ContentType = 'text/csv'; doc.Type = 'csv'; doc.Body = Blob.valueOf(csvContent);
The problem I have is that some characters aren't appearing correctly when I open the file in Excel. Is there a way to fix this, maybe by encoding these characters in my csvContent String? How would I go about doing this?
This is just a guess but try adding a BOM(Byte-order-Mark) to see if it encodes corrctly as Unicode, (Microsoft is known for the use of BOM)
BOM = EncodingUtil.base64decode('77u/').toString();