UTF8 encoding in file extract without the BOM header | Community
Skip to main content
Level 3
November 12, 2020
Solved

UTF8 encoding in file extract without the BOM header

  • November 12, 2020
  • 2 replies
  • 2892 views

Hello,

 

I'm having an issue with a csv file extraction. The need is to have it encoded in UTF8 but ACC adds the byte order mark at the begining of the file.

 

Any idea how to get simple UTF8 extraction or remove the BOM please ?

 

Thank you.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Darren_Bowers

Hi @anasso83525035 - you can get the resulting file name from the CSV extraction activity and run some Javascript to execCommand() some command line sed functions to do this (provided your host is Linux)

https://docs.adobe.com/content/help/en/campaign-classic/technicalresources/api/f-execCommand.html

https://unix.stackexchange.com/a/381263

Cheers

Darren

2 replies

Darren_Bowers
Darren_BowersAccepted solution
Level 9
November 12, 2020

Hi @anasso83525035 - you can get the resulting file name from the CSV extraction activity and run some Javascript to execCommand() some command line sed functions to do this (provided your host is Linux)

https://docs.adobe.com/content/help/en/campaign-classic/technicalresources/api/f-execCommand.html

https://unix.stackexchange.com/a/381263

Cheers

Darren

Level 3
November 16, 2020

Hello @darren_bowers 

 

Thanks for the answer, I have been trying to implement that, but still get the following error :

 

-53
sudo: a password is required

 

Can you please tell me if my CMD command is constructed correctly :

 

//instance.vars.fileToSend is the complete path to the file extracted in the activity before var CMD = '"'+"sed -i '1s/\xEF\xBB\xBF//' "+instance.vars.fileToSend+'"' logInfo('command remove bom ===>'+CMD); var res =execCommand(CMD,true); instance.vars.retour = res[0]; logInfo('Code retour commande : ' + res[0]); logInfo('Résultat commande : ' + res[1]); logInfo('Fin');

Thank you.

Darren_Bowers
Level 9
November 16, 2020

Hi anasso83525035- I tested your code and modified the CMD slightly and it worked on my instance:

var CMD = "sed -i '1s/^\xEF\xBB\xBF//' " + instance.vars.fileToSend;17/11/2020 09:28:59 Workflow finished 17/11/2020 09:28:59 js7 Fin 17/11/2020 09:28:59 js7 Résultat commande : 17/11/2020 09:28:59 js7 Code retour commande : 0 17/11/2020 09:28:59 js7 XSV-350201 Execute the command 'sed -i '1s/^//' /sftp/[redacted]/incoming/exports/Dummy_Test_20201117092859.csv' with user ''. 17/11/2020 09:28:59 js7 command remove bom ===>sed -i '1s/^//' /sftp/[redacted]/incoming/exports/Dummy_Test_20201117092859.csv 17/11/2020 09:28:59 js7 /sftp/[redacted]/incoming/exports/Dummy_Test_20201117092859.csv

Cheers

Darren