How to resolve the algorithm Strip control codes and extended characters from a string step by step in the Bracmat programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Strip control codes and extended characters from a string step by step in the Bracmat programming language

Table of Contents

Problem Statement

Strip control codes and extended characters from a string.

The solution should demonstrate how to achieve each of the following results:

In ASCII, the control codes have decimal codes 0 through to 31 and 127. On an ASCII based system, if the control codes are stripped, the resultant string would have all of its characters within the range of 32 to 126 decimal on the ASCII table. On a non-ASCII based system, we consider characters that do not have a corresponding glyph on the ASCII table (within the ASCII range of 32 to 126 decimal) to be an extended character for the purpose of this task.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Strip control codes and extended characters from a string step by step in the Bracmat programming language

Source code in the bracmat programming language

(  "string of ☺☻♥♦⌂, may include control
characters and other ilk.\L\D§►↔◄
Rødgrød med fløde"
  : ?string1
  : ?string2
& :?newString
&   whl
  ' ( @(!string1:?clean (%@:<" ") ?string1)
    & !newString !clean:?newString
    )
& !newString !string1:?newString
& out$(str$("Control characters stripped:
" str$!newString))
& :?newString
&   whl
  ' ( @(!string2:?clean (%@:(<" "|>"~")) ?string2)
    & !newString !clean:?newString
    )
& !newString !string2:?newString
&   out
  $ ( str
    $ ( "
Control characters and extended characters stripped:
"
        str$!newString
      )
    )
& );

  

You may also check:How to resolve the algorithm Set of real numbers step by step in the Perl programming language
You may also check:How to resolve the algorithm Power set step by step in the PowerShell programming language
You may also check:How to resolve the algorithm Maximum triangle path sum step by step in the Java programming language
You may also check:How to resolve the algorithm Environment variables step by step in the Eiffel programming language
You may also check:How to resolve the algorithm Bitmap/Read an image through a pipe step by step in the Lua programming language