Is there any way to put a string into a token list and have it be interpreted as if the string was a token list itself?
In the snippet below, I want/expect all 3 solutions to display the true-branch (3 times "well, hello there."), but the middle one displays "what?".
What can I do, to solve this? The string, I want to put left in the token list is a given and comes from another procedure - that's something I can not change (in my use case, not the example below, obviously).
\documentclass[varwidth,border=10pt]{standalone}
\usepackage{expl3}
\begin{document}
\ExplSyntaxOn
\clist_new:N \l_some_clist
\clist_put_right:Nn \l_some_clist {hello-world, bye-world}
% only token lists:
\tl_set:Nn \l_testBa_tl {hello}
\tl_set:Nn \l_testBb_tl {-world}
\tl_put_right:No \l_testBa_tl \l_testBb_tl
\clist_if_in:NoTF \l_some_clist \l_testBa_tl {
well,~hello~there.
}{
what?
}
\par
% token list with a string
\tl_set:Nn \l_testA_tl {hello}
\str_set:Nn \l_testA_str {-world}
\tl_put_right:No \l_testA_tl \l_testA_str
\clist_if_in:NoTF \l_some_clist \l_testA_tl {
well,~hello~there.
}{
what?
}
\par
% token list with a string should be interpreted the same as if it would be entered manually:
\tl_set:Nn \l_testA_tl {hello}
\tl_put_right:Nn \l_testA_tl {-world}
\clist_if_in:NoTF \l_some_clist \l_testA_tl {
well,~hello~there.
}{
what?
}
\ExplSyntaxOff
\end{document}
PS.: I have seen Comparing LaTeX3 token list to string, but this does not seem to be about the LaTeX3-strings…
\StringEncodingConvert
from the packagestringenc
and want to compare this string to an item from aclist
.