I'm coding a LaTeX interface for mscgen (another one) and I'm using fancyvrb::VerbatimOut inside a newenvironment to output a part of the tex file into an external file, process it, then import the generated picture.
The signalling chart is indented using tabs (yeah, I know, it's evil) and VerbatimOut does it's job by writing everything 'as-is' into the external file. However, mscgen doesn't likes tab characters, so I'd like to know if it is possible to remove certain characters (or replace them) while using VerbatimOut.
Something like :
\RequirePackage{fancyvrb}
\newenvironment{test}[1]
{\VerbatimOut[codes={\catcode`^^I=9}]{#1}}
{\endVerbatimOut}
Or :
\RequirePackage{fancyvrb}
\newenvironment{test}[1]
{\begingroup\catcode9=9\relax\VerbatimOut{#1}}
{\endVerbatimOut\catcode9=10\relax\endgroup}
Of course there is more code around, but the idea is to get the escaped text without the tabs, or at least replaced with no more than one space instead :
\begin{test}{external_file.txt}
This\n
is\n
# a great \n
test\n
\end{test}
Should produce the following file 'external_file.txt' :
This\n
is\n
# a great \n
test\n
Got some information from the following links :
https://en.wikibooks.org/wiki/TeX/catcode
Tab not as extra alignment tab
How to output a tabulation into a file
How to redefine characters as alignment tabs in a table
Yet I cannot get them to work as I intend.
Or maybe there's a mscgen option to remove input characters, but I didn't found it.

mscgenand adding tabs at the beginning of the lines in their example file; the conversion was flawless. Not sure what the comment is about: if you change the catcode to 10 instead of 9, tabs in the middle of a line will become a space. – egreg Nov 14 '20 at 09:24