![]() PERFORM conv_utf8_2b USING lv_hex lv_unicode_cp. PERFORM conv_utf8_3b USING lv_hex lv_unicode_cp.ĪSSIGN lv_string_utf8+lv_xstr_idx(4) TO TYPE 'C'. PERFORM conv_utf8_4b USING lv_hex lv_unicode_cp.ĪSSIGN lv_string_utf8+lv_xstr_idx(6) TO TYPE 'C'. * apply codepoint conversion, if necessaryĪSSIGN lv_string_utf8+lv_xstr_idx(8) TO TYPE 'C'. * according to its UTF-8 bit distribution pattern and * Parse through the Hex string and identify each Unicode character Lv_string_utf8 = lo_converter->get_buffer( ). Lo_converter->write( EXPORTING data = p_string ). PARAMETERS p_string TYPE char255 LOWER CASE.ĭATA(lo_converter) = cl_abap_conv_out_ce=>create( encoding = 'UTF-8' ). SELECTION-SCREEN BEGIN OF BLOCK b WITH FRAME. REPORT zgp_emoji_conv NO STANDARD PAGE HEADING.ĬONSTANTS c_uc_codepoint TYPE string VALUE ' '. *& Convert Emoji Characters in a Unicode String to Unicode Codepoints As & is an unsafe character in HTML context, it needs to be escaped with & and hence the expected output would be: Test emoji 😀 Now, as per the requirement, the emoji icon ?needs to be converted to 😀 (Code point in Hex). Test emoji ?Īs we see, this string has an emoji icon, technically a unicode character, whose code point is shown below: Let’s consider the below Unicode string as input. How does UTF-8 bit distribution logic work?.How to perform bit manipulation in ABAP?.How to handle the conversion between the data types such as C, I and X and so on?.How to convert from one code page to another in SAP?.How does SAP store the data in the default code page configured?.Though the need for such a solution is very uncommon, the key takeaways from this solution could be our better understanding in the following areas: Here in this article, I’m going to explain what the actual requirement was and how a ABAP solution was provided for the same. ![]() But the reality was quite different upon the realisation that I had bare understanding of how unicode data is stored using UTF-8 encoding. But, recently, there was a unique requirement, wherein it was required to convert the emoji characters in a unicode string to their equivalent Unicode code points in Hexadecimal so that they could be properly displayed in a HTML compliant client.Īs much as it appeared interesting at first, it seemed very straightforward as well. It is very rare that we get to deal with encoding schemes directly in ABAP. ![]() In the recent times, Unicode has become the dominant encoding scheme, of which UTF-8 representation is quite popular, especially with web content. Character encodings are no alien to SAP systems or any computer systems for that matter, as they form the basis for data storage in and communication between computer systems. ![]()
0 Comments
Leave a Reply. |