I am trying to capture punctuation marks and I have a number of macros, two of which are shown in the minimal below:
\documentclass{article}
\usepackage[english]{babel}
\def\isColon#1{%
\ifx:#1
colon!
\else
Not a colon!
\fi}
\def\isPeriod#1{%
\ifx.#1
Period!
\else
Not a period!
\fi}
\begin{document}
\isColon:
\isPeriod.
\end{document}
If the babel language is changed to [french,english] the colon is not captured, as babel makes it active. What modifications are required to the isColon macro to work in both cases?
\iftest is used much less often than\ifx, but as it compares two character codes it is idea here. The\pdfstrcmpprimitive, available in pdfTeX, XeTeX (as\strcmp) and in LuaTeX (using a small piece of Lua) does a general character-based comparison, and is therefore useful in cases where you have two strings and want to ignore category codes. – Joseph Wright Dec 26 '10 at 19:07