How to check and replace UTF BOM characters in a String

Aditya Kumar6
Tera Contributor

How to check and replace UTF BOM characters in a ServiceNow String

We have found that while using flow designer to send data via web service integrations or doing general string data processing an unprompted UTF-8 BOM character is added by the flow designer.

 

This can break 3rd party systems integrations or a general nuisance while working with strings.

 

You can use the below code to check for and replace these UTF-8 BOM characters and create a sanitized data input for your flow to work flawlessly J

 

var aa = '0014�'; // String input

aa = aa.replace(/^\uFEFF/gm, "").replace(/^\u00BB\u00BF/gm,"");

 

for(var i = 0;i<aa.length;i++){

 

  console.log("Test:" + aa[i]);

 

}

 

Happy CODING 😉

 

3 REPLIES 3

Ahmed10
Giga Expert

I noticed that concatenating using pills adds unexpected and unwanted BOM characters. I wonder why that happens.

Aditya Kumar6
Tera Contributor

Yes!!  Thank you. That is a problem. I am not sure when this started but it is big problem when building payloads for third parties.

Liam Powell
Tera Contributor

Looks to be an issue with using Chromium based browsers with flow designer. See this KB: Using flow designer in Chromium based browsers (eg. Chrome 105, Microsoft Edge 105 etc.) causes unex...