Application Development and Automation 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: 
Read only

How to find whether a file is ANSI or UTF-8

Former Member
0 Kudos
1,038

Hello ALL,

I get data in binary format. Based on the data in the internal table, I need to convert it into UTF-8.

I want to convery only the data which are ANSI.

means.

first case: i get the data in ansi. i will convert it into utf-8.

second case. i get the data in utf-8. i will not convert this data.

is there any method from which I can identify from the binary data, that the current data is in ANSI format or UTF-8 format.

Please help.

3 REPLIES 3
Read only

Former Member
0 Kudos
277

Please tell Mukul, that if he uses 2 user ID's to duplicate post questions... then we will randomly delete one of the two user ID's...

Thanks,

Julius

Read only

rainer_hbenthal
Active Contributor
0 Kudos
277

Binary data is not stored in ANSI nor in UTF-8.

Read only

0 Kudos
277

I used the following method to find out.....

OPEN DATASET app_sr FOR OUTPUT IN BINARY MODE.

LOOP AT lt_ascii INTO ls_ascii.

TRANSFER ls_ascii TO app_sr.

ENDLOOP.

CLOSE DATASET app_sr.

COMMIT WORK.

TRY.

CALL METHOD cl_abap_file_utilities=>check_utf8

EXPORTING

file_name = app_sr

IMPORTING

encoding = encoding.

CATCH cx_sy_file_open .

CATCH cx_sy_file_authority .

CATCH cx_sy_file_io .

ENDTRY.

DELETE DATASET app_sr.

IF encoding = 'U'.

                                  • The file is utf-8

ENDIF.