公众号:SAP Technical
本文作者:matinal
前言部分
大家可以关注我的公众号,公众号里的排版更好,阅读更舒适。
正文部分
Conversion
either CREATE + CONVERT
Error rendering macro 'code': Invalid value specified for parameter 'lang'
DATA conv TYPE REF TO cl_abap_conv_in_ce.
DATA buffer(4) TYPE x.
DATA text(100) TYPE c.
buffer = '41424332'. "bytes represent ABC2 in UTF-8
conv = cl_abap_conv_in_ce=>create(
encoding = 'UTF-8' ).
conv->convert(
EXPORTING input = buffer
IMPORTING data = text ).
ASSERT text = `ABC2`.
or CREATE + READ + SKIP_C (buffer of bytes with a pointer)
Error rendering macro 'code': Invalid value specified for parameter 'lang'
DATA buffer(5) TYPE x.
DATA conv TYPE REF TO cl_abap_conv_in_ce.
DATA text(100) TYPE c.
buffer = '4142433235'. "bytes represent ABC25 in UTF-8
conv = cl_abap_conv_in_ce=>create(
encoding = 'UTF-8'
input = buffer ).
CALL METHOD conv->read(
EXPORTING n = 2
IMPORTING data = text ).
ASSERT text = `AB`.
CALL METHOD conv->skip_c(
EXPORTING n = 1 ).
CALL METHOD conv->read(
EXPORTING n = 2
IMPORTING data = text ).
ASSERT text = `25`.
UCCP: converts a unicode code point (hexa representation) into a character
Unique parameter must be a string of exactly 4 characters, in hexadecimal representation (0 to 9, and A to F).
Error rendering macro 'code': Invalid value specified for parameter 'lang'
DATA c2 TYPE c LENGTH 2.
c2 = cl_abap_conv_in_ce=>uccp( '0041' ).
ASSERT c2 = 'A'.
Error rendering macro 'code': Invalid value specified for parameter 'lang'
DATA c4 TYPE c LENGTH 4.
DATA c2 TYPE c LENGTH 2.
c4 = '0041'.
c2 = cl_abap_conv_in_ce=>uccp( c4 ).
ASSERT c2 = 'A'.
Error rendering macro 'code': Invalid value specified for parameter 'lang'
DATA x2 TYPE x LENGTH 2.
x2 = '0041'.
c2 = cl_abap_conv_in_ce=>uccp( x2 ).
ASSERT c2 = 'A'.
UCCPI: converts a unicode code point into a character
Unique parameter must be an integer.
Error rendering macro 'code': Invalid value specified for parameter 'lang'
DATA c2 TYPE c LENGTH 2.
c2 = cl_abap_conv_in_ce=>uccpi( 65 ).
ASSERT c2 = 'A'.