Проверить наличие BOM в UTF файле
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
PARAMETERS: p_file TYPE string DEFAULT '/usr/sap/tmp/testfile.csv' . START-OF-SELECTION. TRY. DATA: lv_bom TYPE sychar01. DATA: lv_encoding TYPE sychar01. cl_abap_file_utilities=>check_utf8( EXPORTING file_name = p_file IMPORTING bom = lv_bom encoding = lv_encoding ). CASE lv_bom. WHEN cl_abap_file_utilities=>no_bom. WRITE: / 'no_bom'. WHEN cl_abap_file_utilities=>bom_utf8. WRITE: / 'bom_utf8'. WHEN cl_abap_file_utilities=>bom_utf16_be. WRITE: / 'bom_utf16_be'. WHEN cl_abap_file_utilities=>bom_utf16_le. WRITE: / 'bom_utf16_le'. ENDCASE. CASE lv_encoding. WHEN cl_abap_file_utilities=>encoding_utf8. WRITE: / 'encoding_utf8'. WHEN cl_abap_file_utilities=>encoding_7bit_ascii. WRITE: / 'encoding_7bit_ascii'. WHEN cl_abap_file_utilities=>encoding_other. WRITE: / 'encoding_other'. ENDCASE. CATCH cx_root INTO DATA(e_txt). WRITE: / e_txt->get_text( ). ENDTRY. |