Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

encoding xml file from ISO-8859-1 to utf-8

MariaJoãoRocha
Contributor
0 Kudos

Hello SAP Community,

I've a xml document that appears to have been written with utf-8 but have the encoding 8859-1. (I've changed in the notepad from 8859 to utf-8 and SAP read the file correctly).

Without changing the xml file how can i force the encoding in the abap?

The code seams not to work.

..

data encoding(10) value 'UTF-8'.

* Creating a document
l_document = l_ixml->create_document( ).

* encoding
l_encoding = encoding.
i_encoding = l_ixml->create_encoding( character_set = l_encoding
byte_order = '0' ).
l_document->set_encoding( encoding = i_encoding ).


* Create a Parser
l_parser = l_ixml->create_parser( stream_factory = l_streamfactory
istream = l_istream
document = l_document ).

the file is opend with

call method cl_gui_frontend_services=>gui_upload
exporting
filename = l_filename
filetype = 'BIN'
importing
filelength = l_xml_table_size
changing
data_tab = l_xml_table
exceptions
others = 19.

What i'm doing wrong?

Thanks. Regards,

Maria João Rocha

2 REPLIES 2

Sandra_Rossi
Active Contributor

I guess the only solution is to modify the xml in memory, between GUI_UPLOAD and PARSE.

Of course, the best solution is to ask for a correct XML file!

MariaJoãoRocha
Contributor
0 Kudos

Yes the best solution would be the correct xml, but I'm afraid that is not possible...

I wish create_encodingworked on the abap code!

Thanks.

Maria João Rocha