‎2014 Feb 25 3:57 PM
I need to convert a xstring to a string, in the following way:
xstring contains 3C3F78 (hex value)
string should contain that value as hex, not as character-value.
How can i do that ?
‎2014 Feb 25 4:45 PM
Hello roberto,
You can try to use this FM: ECATT_CONV_XSTRING_TO_STRING
Regards,
‎2014 Feb 25 4:50 PM
Hi, the problem of this function is that the returned string is converted in utf 16 mode, no matter which parameter i pass in IM_ENCODING. But, for my purpose, i need the string to be in uft 8 mode.
Any idea ?
‎2014 Feb 25 5:07 PM
Hi, if you try this:
CALL FUNCTION 'ECATT_CONV_XSTRING_TO_STRING'
EXPORTING
im_xstring = l_xstr
im_encoding = 'UTF-8'
IMPORTING
ex_string = l_string.
The ex_string is in UTF-8..
How is your expected result?
regards.
‎2014 Feb 25 5:17 PM
In my case in l_xstr i have the utf-8 hex code of a japanese ideogram (i converted it from standard utf 16 to utf 8 with
data: lr_conv type ref to cl_abap_conv_obj.
create object lr_conv
exporting
incode = '4103' "UTF-16
outcode = '4110'. "UTF-8
call method lr_conv->convert
etc..
the hex value of l_xstr is E5B882. I expect the hex value of l_string to be the same, i.e. E5B882. But, actually, the hex value of l_string is 025E which is, by the way, the original utf 16 hex value of the ideogram.
‎2014 Feb 25 5:43 PM
The hex value is supposed to change as the encoding specifies how the bits would be arranged.
Hex value plus the encoding is able to give the exact text. xE5B882 as UTF-8 is same as x025E as UTF-16 when converted to text.
Move the hex value to a string type variable directly does give you a string that has hex value, not char representation.
Message was edited by: Manish Kumar
‎2014 Feb 26 8:24 AM
Thank you Manish. Let's say that, ignoring the conversion thing, i just want to copy the hex value stored in the xstring to the string. Is there a way to do that ?
‎2014 Feb 26 8:47 AM
Yes, just move it to variable of type string.
Data hex type xstring.
Data str type string.
hex = 'E5B882'.
str = hex.
break-point.
‎2014 Feb 25 5:14 PM
Hi,
try below methods/FM
1. DATA: LOC_CONV TYPE REF TO CL_ABAP_CONV_IN_CE,
LOC_XSTRING TYPE XSTRING,
LOC_STRING TYPE STRING.
* Convert XString to String
CALL METHOD CL_ABAP_CONV_IN_CE=>CREATE
EXPORTING
INPUT = LOC_XSTRING
ENCODING = 'UTF-8'
REPLACEMENT = '?'
IGNORE_CERR = ABAP_TRUE
RECEIVING
CONV = LOC_CONV.
TRY.
CALL METHOD LOC_CONV->READ
IMPORTING
DATA = LOC_STRING.
CATCH CX_SY_CONVERSION_CODEPAGE.
*-- Should ignore errors in code conversions
CATCH CX_SY_CODEPAGE_CONVERTER_INIT.
*-- Should ignore errors in code conversions
CATCH CX_PARAMETER_INVALID_TYPE.
CATCH CX_PARAMETER_INVALID_RANGE.
ENDTRY.
2.
CALL FUNCTION 'HR_KR_XSTRING_TO_STRING'
EXPORTING
in_xstring = l_xstring
IMPORTING
out_string = l_string.
‎2014 Feb 25 5:25 PM
Hi rohit, i don't have the fm hr_kr etc in my system. where can i find it ?
‎2014 Feb 25 5:34 PM
Hello Roberto,
Try with the FM's
HR_KR_XSTRING_TO_STRING
CRM_IC_XML_XSTRING2STRING
HR_PSD_CONV_XSTRING_TO_STRING
Regards,
Thanga