Skip to Content

UTF-8 BOM encoding in SCPI doesn't work

Hi Experts,

I am intgerating SuccessFactors with Concur and they want UTF-8 with BOM. I have tried several scripts that's mentioned in below blog along with some changes as well but nothing really works. Do you know if it's still possible to enforce BOM?

https://answers.sap.com/questions/52480/hci-adding-byte-order-mark-bom-to-utf-8-file-conte.html

Concur needs a text file so after converting it to file, I am setting CamelCharsetName as UTF-8 before the script.

I am using below script :

import com.sap.it.api.mapping.*;

import com.sap.gateway.ip.core.customdev.util.Message;

import java.util.HashMap;

import java.nio.charset.StandardCharsets;

def Message processData(Message message) {

Map headerMap = message.getHeaders();

def payload = message.getBody(java.lang.String) as String;

byte[] bom = [0xEF,0xBB,0xBF];

byte[] document = payload.getBytes(StandardCharsets.UTF_8);

byte[] withBom = new byte[bom.length + document.length];

System.arraycopy(bom,0,withBom,0,bom.length);

System.arraycopy(document,0,withBom,bom.length,document.length);

String s2 = new String(withBom); message.setBody(s2);

return message;

}

I can see some special characters being populated but when I open the file in notepad++ it still shows encoding as UTF-8. Could you please help?

Cheers,

Pratibha

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

0 Answers