2023 Mar 22 7:38 AM
Hello I'm looking for method to convert string to array of bytes.
I need something what returns result as:
C#:
byte[] arr;
string str;
str = "that is a string";
arr = System.Text.ASCIIEncoding.UTF8.GetBytes(str);
or
Java:
String str = "string";
byte arr[] = str.getBytes();
I have tried to use FM 'SCMS_STRING_TO_XSTRING' or 'HR_KR_STRING_TO_XSTRING' but it doesn't work properly.
I'm obligated in specification to convert string to array of bytes and then make RSA encryption using public key and array of bytes.SPAN { font-family: "Courier New"; font-size: 10pt; color: #000000; background: #FFFFFF; }.L0S33 { color: #4DA619; }
2023 Mar 22 8:37 AM
You have a lot of method to convert in the class CL_BCS_CONVERT
2023 Mar 22 11:54 AM
Hi,
Try this, it will work.
1 - SCMS_STRING_TO_XSTRING
2 - SCMS_XSTRING_TO_BINARY
2023 Mar 22 6:36 PM
Converting characters into bytes means 2 things:
and the combination of the two above can lead to even more possibilities.
Please indicate your exact issue/requirement.
2023 Mar 23 8:52 AM
To convert binary to string, you can use this example:
DATA: lv_encode TYPE abap_encod.
lv_encode = cl_abap_codepage=>sap_codepage( 'UTF-8' ).
lr_converter = cl_abap_conv_in_ce=>create( input = <doc>
encoding = lv_encode
replacement = '' ).
lr_converter->read( EXPORTING n = xstrlen( <doc> )
IMPORTING data = <wa_doc>-doc ).
To convert string back to binary, you can use class CL_ABAP_CONV_OUT_CE