For some reasons, I need to choose one or two character to delimit placeholders in LaTeX3 strings, like:
I like ``NAME`OF`FRUITS``
in order to allow a safer replace (hence the doubling of the first and last symbol to get rid of ambiguity) + easy reading.
But finding a good character is not that easy:
- Many characters have special meanings for LaTeX and babel that redefine many characters, like
^,_,-,;,~,#,@… I’d prefer to avoid using them to avoid espace nightmares. And I don’t know all packages, and I’m sure that some popular packages can redefine other chars. - I’m thinking that non-ascii characters might be an issue since they might be interpreted differently on different computers. In particular, I don’t know if
°could be a valid choice.
Is there a list of character that are basically as safe as letters to use?
EDIT
Here is a more concrete use case I want to consider. I basically want to be sure that no matter what is around \robExtGetPlaceholder{__VEGETABLE__}, the _ should not be turned into another symbol, even after loading a popular package.
\documentclass{article}
\ExplSyntaxOn
\seq_clear_new:N \l_robExt_placeholders_seq
% Make sure that the placeholder is in the list \l_robExt_placeholders_seq.
% This should automatically be called by other tools
\NewDocumentCommand{\robExtAddPlaceholderToList}{m}{
\seq_put_left:Nn \l_robExt_placeholders_seq { #1 }
}
\NewDocumentCommand{\robExtPlaceholderFromContent}{mm}{
\str_gset:cn { l_robExt_placeholder_#1_str } {#2}
\message{aaaaaaaaaaaaa#1}
\robExtAddPlaceholderToList{#1}
}
\NewDocumentCommand{\robExtDebugPlaceholder}{sm}{
\message{Placeholder ~ #2 ~ contains: ~ \use:c{l_robExt_placeholder_#2_str}}
\IfBooleanTF{#1}{\cs_show:c { l_robExt_placeholder_#2_str }}{}
}
\NewDocumentCommand{\robExtGetPlaceholder}{m}{
\use:c{l_robExt_placeholder_#1_str}
}
\NewDocumentCommand{\robExtDebugPlaceholdersContents}{s}{
\message{List ~ of ~ placeholders:}
\seq_map_inline:Nn \l_robExt_placeholders_seq {\robExtDebugPlaceholder{##1}}
\IfBooleanTF{#1}{\cs_show:N \l_robExt_placeholders_seq}{}
}
%% I also have other commands, for instance to replace placeholders etc...
\ExplSyntaxOff
\begin{document}
\robExtPlaceholderFromContent{FRUIT}{Orange}
\robExtPlaceholderFromContent{SENTENCE}{I like FRUIT and VEGETABLE}
$\robExtPlaceholderFromContent{VEGETABLE}{Salad}$
\robExtDebugPlaceholdersContents*
Does it mean that whatever think is put around the get placeholder here, it will still be interpreted correctly? (no escape, no weird replacement of the character with another character…)
$1 + \robExtGetPlaceholder{FRUIT} + \robExtGetPlaceholder{VEGETABLE}$
\end{document}
\def\foo#1#2{...}which does not require the character to be a single token, or that it has any tex definition, or do you require a token that has a tex definition (and if so can it be a csname token such as\starthere– David Carlisle Jul 10 '23 at 09:13\getValuePlaceholder{°°MY°FRUIT°°}without it being interpreted in a weird way due to babel, csquote, whatever, I want to be able to put this symbol directly in a string, and I want the strings to be strictly identical (when computing md5sum for instance), even if two strings are created from files with different encodings (don't want my utf-8 library to be broken on windows). – tobiasBora Jul 10 '23 at 11:49strtype so everything is catcode 12 and has no definition at all. – David Carlisle Jul 10 '23 at 19:49