BOM at start of IFS stream file

Discussions related to HTTPAPI (An HTTP Client Package for RPG programming.) http://www.scottklement.com/httpapi/
Post Reply
msddcb
Posts: 31
Joined: Wed Jul 28, 2021 5:12 am

BOM at start of IFS stream file

Post by msddcb »

We are using httpapir4 procedure http_req to retrieve a list from Azure.
This list is returned in xml format.
The file is saved to the IFS
The first 3 characters are invalid for xml
Is there a way to not get these characters.
This is the first part of the stream file - <?xml version="1.0" encoding="utf-8"?>
This first 3 bytes are x'EFBBBF'

This is the call
rc = http_req ( pMode -- GET
: wrkURL
: pReceiveFile
: *OMIT
: *OMIT
: wrkAPIbody
: 'text/xml' );

Thank you for any suggestions

Don
peder udesen
Posts: 22
Joined: Thu Jul 29, 2021 8:00 am

Re: BOM at start of IFS stream file

Post by peder udesen »

Depending on the version of the operating system the problem is that the file has the wrong CCSID.
I assume it is 1252 ( Windows character set )

You have to change it to 1208 ( UTF-8 )
CHGATR OBJ('myFile.xml') ATR(*CCSID) VALUE(1208)
Scott Klement
Site Admin
Posts: 872
Joined: Sun Jul 04, 2021 5:12 am

Re: BOM at start of IFS stream file

Post by Scott Klement »

Clearly you know it is a BOM, since you made this the subject of the message. Why do you think it is invalid for XML? It certainly is not.

In any case, these don't come from HTTPAPI. They are part of the file sent from the other side.
msddcb
Posts: 31
Joined: Wed Jul 28, 2021 5:12 am

Re: BOM at start of IFS stream file

Post by msddcb »

Thanks Scott,
I am going by the advise of others that is is a Byte Order Mark but Mr Google seems to agree.
I am saying that when I try and do an XML-INTO that it fails with invalid XML as it does not like the first three bytes.
If we run the same request in Postman we do not get the BOM.
We have added a process to rewrite the first part of the XML stream file in the IFS to bypass this problem.
However I am of stubborn nature and am trying to understand why we are getting this and how we could avoid the BOM or perhaps why it is there at all.
If you have any comments that would help in my understanding that would be most appreciated.

Thank you
Don
Scott Klement
Site Admin
Posts: 872
Joined: Sun Jul 04, 2021 5:12 am

Re: BOM at start of IFS stream file

Post by Scott Klement »

Of course Postman received it. It doesn't show it to you because it is part of UTF-8, not intended to be visible to humans.

If you save it to the IFS in a file that is marked with CCSID 1208 (which means UTF-8) you won't see it in tools like DSPF/EDTF, either.

Most likely you are not setting the CCSID of the file correctly, so you are telling the system that it's not UTF-8, and that's why you're seeing it. But, then Peder already told you that.
Post Reply