I have some code that convert some macros to a string to write, but unfortunately when a character # is given as input it is turned into ##. I tried to play with catcodes, but seems like it is not effective:
The following code shows:
Hey \notexistingbutnoproblem ##
instead of
Hey \notexistingbutnoproblem #
MWE:
\documentclass[]{article}
\begin{document}
\ExplSyntaxOn
\NewDocumentCommand{\defineString}{m}{
\char_set_catcode_letter:N #
\str_set:Nn \l_test_str {#1}
% My failed other try:
% \tl_set_rescan:Nnn \l_test_str {\char_set_catcode_letter:N #}{#1}
% \tl_to_str:n \l_test_str
w}
\NewDocumentCommand{\showString}{}{
\show\l_test_str
}
\ExplSyntaxOff
\defineString{Hey \notexistingbutnoproblem #}
\showString
\end{document}
\showcommand you are using – David Carlisle Sep 08 '23 at 04:50