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

UTF-8

Former Member
0 Likes
1,349

Hi Experts,

I have a problem where the file generated as UTF-8 format but the the checking always shown 'Non UTF-8'?



  OPEN DATASET docid FOR OUTPUT IN TEXT MODE ENCODING UTF-8.

  LOOP AT i_outfile.
    TRANSFER i_outfile TO docid LENGTH 1000.
  ENDLOOP.
  CLOSE DATASET docid.

  IF cl_abap_file_utilities=>check_for_bom( docid ) = cl_abap_file_utilities=>bom_utf8.
    WRITE 'UTF-8'.
  ELSE.
    WRITE 'Non UTF-8'.
  ENDIF.

  

Hope you can shed some light here.

9 REPLIES 9
Read only

Former Member
0 Likes
1,049

Can anyone please help?

Read only

former_member156446
Active Contributor
0 Likes
1,049

try this:

OPEN DATASET docid FOR OUTPUT IN TEXT MODE ENCODING UTF-8.
 if sy-subrc NE 0.
exit.
else.
  LOOP AT i_outfile.
    TRANSFER i_outfile TO docid LENGTH 1000.
  ENDLOOP.
  CLOSE DATASET docid.
endif.

Read only

Former Member
0 Likes
1,049

Thanks Jay for proposing solution. However, there is no problem with OPEN DATASET ... ENCODING UTF-8 statement and the UTF-8 file created successfully.

Read only

0 Likes
1,049

try it in byte mode rather than text mode. uTF-8 and UTF-16 etc are related to bytes...

[UNICODE INTERFACES u2013 DATA EXCHANGE BETWEEN UNICODE AND NON-UNICODE SYSTEMS|https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/10fe20ed-b611-2a10-a2ba-d5665779c10c]

Read only

Former Member
0 Likes
1,049

Jay,

Do you mean OPEN DATASET ... IN BINARY MODE? There is no such syntax as IN BYTE MODE. I tried BINARY MODE but not working.

Read only

Former Member
0 Likes
1,049

To make my question clearer,

How to create a UTF-8 file in application server with BOM (Byte-Order Mark)?

Read only

Former Member
0 Likes
1,049

Solved by myself. Thanks.

Read only

0 Likes
1,049

Hi Girish

I am having a similar problem, when I transfer the data to .DAT file..some sp. char appers with £ sign.

How did you solved the problem, if you can guide me that will be great.

thanks

Anup

Read only

0 Likes
1,049

As usual : someone find the answer and do not post it... Worse!! He comes to say he has found it and do not post it... We see that too many times on this forum.

Anyway here's my solution in this post : helped by the previous answers !

I had to pass through an xstring for convertion but it's quite easy.