标签:
DATA: xstr TYPE xstring.
DATA: l_codepage(4) TYPE n .
DATA: l_encoding(20).
**********字符集名与内码转换
"将外部字符集名转换为内部编码
CALL FUNCTION ‘SCP_CODEPAGE_BY_EXTERNAL_NAME‘
EXPORTING
external_name = ‘UTF-8‘
IMPORTING
sap_codepage = l_codepage.
l_encoding = l_codepage.
**********编码
DATA: convout TYPE REF TO cl_abap_conv_out_ce.
"创建编码对象
convout = cl_abap_conv_out_ce=>create( encoding = l_encoding ).
convout->write( data = ‘江正军‘)."编码
xstr = convout->get_buffer( )."获取码流
WRITE: / xstr."E6B19FE6ADA3E5869B
**********解码
DATA: convin TYPE REF TO cl_abap_conv_in_ce.
"创建解码对象
convin = cl_abap_conv_in_ce=>create( encoding = l_encoding input = xstr ).
DATA: str TYPE string.
CALL METHOD convin->read"解码
IMPORTING data = str.
WRITE: / str."江正军
标签:
原文地址:http://www.cnblogs.com/jiangzhengjun/p/4265650.html