<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Converting control characters to spaces in a Unicode program? in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/converting-control-characters-to-spaces-in-a-unicode-program/m-p/1464626#M218932</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Works on Non-UC, and i'm expectiong it should work on other systems too.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Sridhar&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 25 Aug 2006 17:51:35 GMT</pubDate>
    <dc:creator>sridhar_k1</dc:creator>
    <dc:date>2006-08-25T17:51:35Z</dc:date>
    <item>
      <title>Converting control characters to spaces in a Unicode program?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/converting-control-characters-to-spaces-in-a-unicode-program/m-p/1464621#M218927</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I want to take an ASCII character string and convert any&lt;/P&gt;&lt;P&gt;ASCII Control Characters to Spaces.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In a non-Unicode program, I define the following hex constant:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CONSTANTS: c_control_to_space(64) TYPE x VALUE&lt;/P&gt;&lt;P&gt;  '00200120022003200420052006200720082009200A200B200C200D200E200F20' &amp;amp;&lt;/P&gt;&lt;P&gt;  '10201120122013201420012016201720182019201A201B201C201D201E201F20'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I then execute the following TRANSLATE statement:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      TRANSLATE w_transcript USING c_control_to_space.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What would be the "approved" method of accomplishing the same effect&lt;/P&gt;&lt;P&gt;in a Unicode program?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Aug 2006 03:54:41 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/converting-control-characters-to-spaces-in-a-unicode-program/m-p/1464621#M218927</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-08-25T03:54:41Z</dc:date>
    </item>
    <item>
      <title>Re: Converting control characters to spaces in a Unicode program?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/converting-control-characters-to-spaces-in-a-unicode-program/m-p/1464622#M218928</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;you can use the constants in cl_abap_char_utilities to convert the usual ones  (HORIZONTAL_TAB etc) but your code is a bit different, all it doing is converting hex values of 00 - 1F to x'20' which is spaces. (Although there looks to be a slight bug in it if you look at this fragment '....142001201620....' after 1420 there is 0120 which is already catered for, I think it should actually be 1520).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can use something like this instead:&lt;/P&gt;&lt;P&gt;Data x type x.                            &lt;/P&gt;&lt;P&gt;Field-symbols &amp;lt;hex&amp;gt; type x.               &lt;/P&gt;&lt;P&gt;Field-symbols &amp;lt;char&amp;gt; type c.              &lt;/P&gt;&lt;P&gt;                                          &lt;/P&gt;&lt;P&gt;Assign X to &amp;lt;hex&amp;gt; .                       &lt;/P&gt;&lt;P&gt;Assign &amp;lt;hex&amp;gt; to &amp;lt;char&amp;gt; casting.           &lt;/P&gt;&lt;P&gt;                                          &lt;/P&gt;&lt;P&gt;Do 32 times.                              &lt;/P&gt;&lt;P&gt; X = sy-index - 1.                        &lt;/P&gt;&lt;P&gt; replace all occurrences of &amp;lt;char&amp;gt; in w_transcript  with ''.&lt;/P&gt;&lt;P&gt;Enddo.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Aug 2006 05:22:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/converting-control-characters-to-spaces-in-a-unicode-program/m-p/1464622#M218928</guid>
      <dc:creator>former_member186741</dc:creator>
      <dc:date>2006-08-25T05:22:02Z</dc:date>
    </item>
    <item>
      <title>Re: Converting control characters to spaces in a Unicode program?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/converting-control-characters-to-spaces-in-a-unicode-program/m-p/1464623#M218929</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Neil,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;First, thank you for pointing out my typo. You are correct that the "0120" in the second line of the literal was intended to be "1520".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Second, thank you for your suggestion. Based on your idea, I tried something similar, but not exactly what you suggested. In particular, since I can't figure out how to construct the constant that I want, I used your idea to construct it as  a variable, as follows:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  DATA number TYPE i.&lt;/P&gt;&lt;P&gt;  DATA offset TYPE i.&lt;/P&gt;&lt;P&gt;  DATA hex(4) TYPE x.&lt;/P&gt;&lt;P&gt;  FIELD-SYMBOLS &amp;lt;char&amp;gt; TYPE c.&lt;/P&gt;&lt;P&gt;  ASSIGN hex TO &amp;lt;char&amp;gt; CASTING TYPE c.&lt;/P&gt;&lt;P&gt;  DATA w_control_to_space(64) TYPE c.&lt;/P&gt;&lt;P&gt;  DO 32 TIMES.&lt;/P&gt;&lt;P&gt;    hex = sy-index - 1.&lt;/P&gt;&lt;P&gt;    offset = 2 * ( sy-index - 1 ).&lt;/P&gt;&lt;P&gt;    number = STRLEN( &amp;lt;char&amp;gt; ).&lt;/P&gt;&lt;P&gt;    IF number GT 1.&lt;/P&gt;&lt;P&gt;      SUBTRACT 1 FROM number.&lt;/P&gt;&lt;P&gt;      SHIFT &amp;lt;char&amp;gt; LEFT BY number PLACES.&lt;/P&gt;&lt;P&gt;    ENDIF.&lt;/P&gt;&lt;P&gt;    w_control_to_space+offset(1) = &amp;lt;char&amp;gt;.&lt;/P&gt;&lt;P&gt;  ENDDO.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;After having constructed "w_control_to_space", I can now use the TRANSLATE statement:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  TRANSLATE w_transcript USING w_control_to_space.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This code passes the Unicode syntax checks and works correctly on a non-Unicode system. I don't have access to a Unicode system on which to run it. I'd appreciate any feedback on this approach - especially if someone can actually test it on a Unicode system.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Aug 2006 15:09:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/converting-control-characters-to-spaces-in-a-unicode-program/m-p/1464623#M218929</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-08-25T15:09:53Z</dc:date>
    </item>
    <item>
      <title>Re: Converting control characters to spaces in a Unicode program?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/converting-control-characters-to-spaces-in-a-unicode-program/m-p/1464624#M218930</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try this code to replace all occurances of control chars between 00 to 1F. I don't have unicode system to test this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;data: len type i,
      off type i,
      hex(2) type x value '001F'. "1F00 on Windows box

data asci_str(100) type c.

field-symbols &amp;lt;fs&amp;gt; type any.

len = strlen( asci_str ).

while off lt len.
  assign asci_str+off(1) to &amp;lt;fs&amp;gt; casting type x.
  if &amp;lt;fs&amp;gt; le hex.
    asci_str+off(1) = ' '.
  endif.
  add 1 to off.
endwhile.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Sridhar&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Aug 2006 15:40:21 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/converting-control-characters-to-spaces-in-a-unicode-program/m-p/1464624#M218930</guid>
      <dc:creator>sridhar_k1</dc:creator>
      <dc:date>2006-08-25T15:40:21Z</dc:date>
    </item>
    <item>
      <title>Re: Converting control characters to spaces in a Unicode program?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/converting-control-characters-to-spaces-in-a-unicode-program/m-p/1464625#M218931</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sridhar K included the line&lt;/P&gt;&lt;P&gt;hex(2) type x value '001F'. "1F00 on Windows box&lt;/P&gt;&lt;P&gt;which points out that I didn't account for the "endian"ness of a Unicode system. Does the following version work correctly on all of non-Unicode, Big-endian Unicode, and Little-endian Unicode systems?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  CLASS cl_abap_char_utilities DEFINITION LOAD.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  DATA offset TYPE i.&lt;/P&gt;&lt;P&gt;  DATA hex(4) TYPE x.&lt;/P&gt;&lt;P&gt;  FIELD-SYMBOLS &amp;lt;char&amp;gt; TYPE c.&lt;/P&gt;&lt;P&gt;  ASSIGN hex TO &amp;lt;char&amp;gt; CASTING TYPE c.&lt;/P&gt;&lt;P&gt;  DATA w_control_to_space(64) TYPE c.&lt;/P&gt;&lt;P&gt;  DO 32 TIMES.&lt;/P&gt;&lt;P&gt;    hex = sy-index - 1.&lt;/P&gt;&lt;P&gt;    offset = 2 * ( sy-index - 1 ).&lt;/P&gt;&lt;P&gt;    CASE cl_abap_char_utilities=&amp;gt;charsize.&lt;/P&gt;&lt;P&gt;      WHEN 1.&lt;/P&gt;&lt;P&gt;        SHIFT hex LEFT BY 3 PLACES IN BYTE MODE.&lt;/P&gt;&lt;P&gt;      WHEN 2.&lt;/P&gt;&lt;P&gt;        IF cl_abap_char_utilities=&amp;gt;endian EQ 'B'.&lt;/P&gt;&lt;P&gt;          SHIFT hex LEFT BY 2 PLACES IN BYTE MODE.&lt;/P&gt;&lt;P&gt;        ELSE.&lt;/P&gt;&lt;P&gt;          SHIFT hex LEFT BY 3 PLACES IN BYTE MODE.&lt;/P&gt;&lt;P&gt;        ENDIF.&lt;/P&gt;&lt;P&gt;    ENDCASE.&lt;/P&gt;&lt;P&gt;    w_control_to_space+offset(1) = &amp;lt;char&amp;gt;.&lt;/P&gt;&lt;P&gt;  ENDDO.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TRANSLATE w_transcript USING w_control_to_space.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Aug 2006 17:00:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/converting-control-characters-to-spaces-in-a-unicode-program/m-p/1464625#M218931</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-08-25T17:00:31Z</dc:date>
    </item>
    <item>
      <title>Re: Converting control characters to spaces in a Unicode program?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/converting-control-characters-to-spaces-in-a-unicode-program/m-p/1464626#M218932</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Works on Non-UC, and i'm expectiong it should work on other systems too.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Sridhar&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Aug 2006 17:51:35 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/converting-control-characters-to-spaces-in-a-unicode-program/m-p/1464626#M218932</guid>
      <dc:creator>sridhar_k1</dc:creator>
      <dc:date>2006-08-25T17:51:35Z</dc:date>
    </item>
  </channel>
</rss>

