How to save a file using saveFile() function without BOM

Description

Issue: When we use the saveFile() JS function in Adobe Campaign and select the encoding to be UTF-8, it saves the file in UTF-8 with BOM format.

SyntaxsaveFile (“Text to be saved”, “Server location where the file will be saved/File name”,“Encoding”);

Resolution

By defalut, when we use the function saveFile() as:

saveFile (“Text to be saved”, “Server location where the file will be saved/File name”,“utf-8”);

The file is saved with the format UTF-8 with BOM

What is BOM: 

The byte order mark (BOM) is a Unicode character, U+FEFF BYTE ORDER MARK (BOM), whose appearance as a magic number at the start of a text stream can signal several things to a program reading the text:

  • The byte order, or endianness, of the text stream;
  • The fact that the text stream’s encoding is Unicode, to a high level of confidence;
  • Which Unicode encoding the text stream is encoded as.

To avoid this, the resolution is to skip the encoding part in the syntax of the function. So use it like:

saveFile (“Text to be saved”, “Server location where the file will be saved/File name”);

This will save the file in UTF-8 format but without BOM

On this page