I need a command to replace (erase) the characters ·
and |
from a string.
Consider the following naive code:
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{stringstrings}
\newcommand\mycommand[1]{%
\convertchar[q]{#1} {·}{}%
\convertchar[v]{\thestring}{|}{}}
\begin{document}
\mycommand{foo·bar|baz}
\end{document}
It gives a stack exceeded
error; I think the reason is that the occurrences of ·
are passed as \IeC {\textperiodcentered }
to \convertchar
.
Also, the substitution of |
is not working. I think that's due to the font encoding as suggested by the manual of stringstrings
.
Fiddling with \unexpanded
and \detokenize
got me nowhere: I don't quite get what is happening, so I just made a mess.
What is the best way to write such a command? Why?
(An implementation using xstring
is equally welcome; I tried, obtaining essentially the same results.)