Campaign | 如何在不使用BOM的情況下使用saveFile()函式儲存檔案

說明 description

問題:當我們使用 saveFile() Adobe Campaign中的JS函式並選取編碼為UTF-8,則會以UTF-8格式儲存檔案並採用BOM格式。

Syntax: saveFile ("Text to be saved", "Server location where the file will be saved/File name","Encoding");

解決方法 resolution

根據預設,當我們使用函式時 saveFile() 作為:

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

檔案會以UTF-8格式與BOM儲存

什麼是BOM:

位元組順序標籤(BOM)是Unicode字元,U+FEFF  位元組順序標籤  (BOM),在文字串流開始時,其外觀會變成魔術數字,會向讀取文字的程式發出幾個訊號:

  • 文字資料流的位元組順序或位元組順序;
  • 事實上,文字資料流的編碼為Unicode,擁有高度的信賴度;
  • 文字串流編碼為哪種Unicode。

為了避免此問題,解決方法是在函式的語法中略過編碼部分。 因此使用方式如下:

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

這會將檔案以UTF-8格式儲存,但不使用BOM

recommendation-more-help
3d58f420-19b5-47a0-a122-5c9dab55ec7f