Initials of Torsten Berg (called Torsten Reincke earlier) here on the Wiki.
LV tr is also a Unix filter for translating characters .
There are several options for tr. Perhaps a Tcl version could be written and added to fileutil.
It appears that the tr specs are:
- read stdin and write stdout
- In function 1, take 2 strings. string1 contains single characters to be sought within the stdin. string2 contains a map of single characters corresponding to each character in string1. The resulting output replaces each occurrence that matches an entry in string1 with the corresponding string2 character. This sounds a lot like string map.
- note that one can use character class expressions or equivalence class expressions in string1 - unless one is doing case conversion
- In function 2 (-c) , complement the set of characters specified by string1, then replace them with the characters in string2.
- Function 3 (-d) indicates that all occurrences of characters from string1 are deleted.
- Function 4 (-s) indicates that, after functions 1-3 are complete, sequentially repeated instances of the same character will be replaced by one instance of the character, if the character is found in string2.
- if string1 contains a character class and Function 4 is being performed, then string1 will be treated as if all characters of that class were specified.
- if string2 contains a character class such as :upper: or :lower:, then it will be treated as containing only those characters matching the string1 characters.
- A character in string1 or string2 can be either the actual character, a member of a character class, an octal sequence, or a special meta escape sequence such as \a, \b, \f, \r, \t, and \v.