cancel
Showing results for 
Search instead for 
Did you mean: 

SAP CPI - Invalid white space character (0xf) in text to output

selvakumar_5984
Explorer
0 Kudos

Dear All,

I am trying to Convert a Json to XML. In the input json, I have a hexa decimal character - \u000f

Because of that, JSON to XML conversion fails. I am trying to replace the hexa decimal character by using replace method in the String. But it is not getting replaced. The same code works well in my local groovy script.

Input Payload:

{"address":"\u000fF"}

Error Message:

An internal server error occured: Invalid white space character (0xf) in text to output (in xml 1.1, could output as a character entity).

Note: When I tried to see the length of the Body Message, I am getting it as 21 for the input payload. But in my local, its length is 16. The Hexa decimal character is not recognized as single character in SCPI.

Please provide your suggestion to solve the issue

Accepted Solutions (0)

Answers (4)

Answers (4)

r_herrmann
Active Contributor

Hi Selvakumar,

have your tried double escaping the backslash? This one works for me:

body = body.replaceAll("\\u000f",'')

Best regards,
Raffael

selvakumar_5984
Explorer
0 Kudos

I have tried replaceAll, and it is not working as expected.

0 Kudos

Hi, I solved this problem using this, Coding a literal backslash into a regex requires 4 backslashes in the java/groovy literal String, because the backslashes are escaped twice - once in java/groovy and again in the regex.

def jsonOP = message.getBody(String.class);
jsonOP=jsonOP.toString().replaceAll("\\\\u[0-9a-fA-F]{4}", "") //replacing non-printable characters
message.setBody(jsonOP);
return message;
former_member608139
Active Participant
0 Kudos

with "\\"

former_member608139
Active Participant
0 Kudos

Try to use replaceAll method as can you see below:

xx0F = x0F.replaceAll("\\u000f","")

selvakumar_5984
Explorer
0 Kudos

I have tried replaceAll, and it is not working as expected.