How to resolve the algorithm Strip control codes and extended characters from a string step by step in the zkl 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 zkl 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 zkl programming language
Source code in the zkl programming language
var ctlCodes=([1..31].pump(String,"toChar") +(127).toChar());
var extdChars=[127..255].pump(String,"toChar");
var test = "string of ☺☻♥♦⌂, control characters(\t\b\e) and other ilk.♫☼§►↔◄";
test.println("<< test string");
(test-ctlCodes).println("<< no control chars");
(test-extdChars).println("<< no extended chars");
(test-extdChars-ctlCodes).println("<< text");
You may also check:How to resolve the algorithm Mandelbrot set step by step in the Rust programming language
You may also check:How to resolve the algorithm Associative array/Merging step by step in the Clojure programming language
You may also check:How to resolve the algorithm Boolean values step by step in the Monte programming language
You may also check:How to resolve the algorithm Call a function step by step in the R programming language
You may also check:How to resolve the algorithm Runtime evaluation step by step in the Quackery programming language