<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Active characters again</title>
	<atom:link href="http://www.texdev.net/2009/12/09/active-characters-again/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.texdev.net/2009/12/09/active-characters-again/</link>
	<description>Coding in the TeX world</description>
	<lastBuildDate>Tue, 07 Feb 2012 20:07:12 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Joseph Wright</title>
		<link>http://www.texdev.net/2009/12/09/active-characters-again/#comment-1917</link>
		<dc:creator>Joseph Wright</dc:creator>
		<pubDate>Wed, 16 Dec 2009 17:25:16 +0000</pubDate>
		<guid isPermaLink="false">http://www.texdev.net/?p=575#comment-1917</guid>
		<description>No problem Leo: I hope it&#039;s useful.</description>
		<content:encoded><![CDATA[<p>No problem Leo: I hope it&#8217;s useful.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: leo</title>
		<link>http://www.texdev.net/2009/12/09/active-characters-again/#comment-1897</link>
		<dc:creator>leo</dc:creator>
		<pubDate>Sun, 13 Dec 2009 19:32:05 +0000</pubDate>
		<guid isPermaLink="false">http://www.texdev.net/?p=575#comment-1897</guid>
		<description>Thank you, Joseph. I will come back to that code later when I finish my task at hand.

Best,

Leo</description>
		<content:encoded><![CDATA[<p>Thank you, Joseph. I will come back to that code later when I finish my task at hand.</p>
<p>Best,</p>
<p>Leo</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joseph Wright</title>
		<link>http://www.texdev.net/2009/12/09/active-characters-again/#comment-1878</link>
		<dc:creator>Joseph Wright</dc:creator>
		<pubDate>Fri, 11 Dec 2009 18:17:12 +0000</pubDate>
		<guid isPermaLink="false">http://www.texdev.net/?p=575#comment-1878</guid>
		<description>I should add that expl3 includes some more refinements to that code, mainly to do with # tokens. However, the principal is obvious.</description>
		<content:encoded><![CDATA[<p>I should add that expl3 includes some more refinements to that code, mainly to do with # tokens. However, the principal is obvious.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joseph Wright</title>
		<link>http://www.texdev.net/2009/12/09/active-characters-again/#comment-1873</link>
		<dc:creator>Joseph Wright</dc:creator>
		<pubDate>Fri, 11 Dec 2009 13:44:33 +0000</pubDate>
		<guid isPermaLink="false">http://www.texdev.net/?p=575#comment-1873</guid>
		<description>Hello Leo,

Assuming you have a recent pdfTeX (or XeTeX), then the following implements the same idea as \tl_replace_all_in:Nnn but without expl3:

&lt;pre&gt;
\documentclass{article}
\makeatletter
\newtoks\replace@toks
\newcommand\replace@all@in[3]{%
  \replace@toks{}%
  \long\def\replace@all@aux##1#2##2\@nil{%
    \if@no@value{##2}%
      {%
        \replace@toks\expandafter\expandafter\expandafter
          {\expandafter\the\expandafter\replace@toks##1}%
      }%
      {%
        \replace@toks\expandafter\expandafter\expandafter
          {\expandafter\the\expandafter\replace@toks##1#3}%
        \replace@all@aux\@empty##2\@nil
      }%
  }%
  \@firstofone{\expandafter\replace@all@aux\expandafter\@empty}%
  #1#2\no@value\@nil
  \edef#1{\the\replace@toks}%
}
\newcommand\replace@all@aux{}
\newcommand\if@no@value[1]{%
  \ifnum\pdfstrcmp{\noexpand\no@value}{\unexpanded{#1}}=\z@\relax
    \expandafter\@firstoftwo
  \else
    \expandafter\@secondoftwo
  \fi
}
\makeatother
\begin{document}
\makeatletter
\def\test{Hello&#124;world}
\replace@all@in\test{&#124;}{ }
\test
\makeatother
\end{document}
&lt;/pre&gt;

This relies on \pdfstrcmp. If it&#039;s not available, then some more code is needed for the comparison test (to do it safely, at least).

Joseph</description>
		<content:encoded><![CDATA[<p>Hello Leo,</p>
<p>Assuming you have a recent pdfTeX (or XeTeX), then the following implements the same idea as \tl_replace_all_in:Nnn but without expl3:</p>
<pre>
\documentclass{article}
\makeatletter
\newtoks\replace@toks
\newcommand\replace@all@in[3]{%
  \replace@toks{}%
  \long\def\replace@all@aux##1#2##2\@nil{%
    \if@no@value{##2}%
      {%
        \replace@toks\expandafter\expandafter\expandafter
          {\expandafter\the\expandafter\replace@toks##1}%
      }%
      {%
        \replace@toks\expandafter\expandafter\expandafter
          {\expandafter\the\expandafter\replace@toks##1#3}%
        \replace@all@aux\@empty##2\@nil
      }%
  }%
  \@firstofone{\expandafter\replace@all@aux\expandafter\@empty}%
  #1#2\no@value\@nil
  \edef#1{\the\replace@toks}%
}
\newcommand\replace@all@aux{}
\newcommand\if@no@value[1]{%
  \ifnum\pdfstrcmp{\noexpand\no@value}{\unexpanded{#1}}=\z@\relax
    \expandafter\@firstoftwo
  \else
    \expandafter\@secondoftwo
  \fi
}
\makeatother
\begin{document}
\makeatletter
\def\test{Hello|world}
\replace@all@in\test{|}{ }
\test
\makeatother
\end{document}
</pre>
<p>This relies on \pdfstrcmp. If it&#8217;s not available, then some more code is needed for the comparison test (to do it safely, at least).</p>
<p>Joseph</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: leo</title>
		<link>http://www.texdev.net/2009/12/09/active-characters-again/#comment-1872</link>
		<dc:creator>leo</dc:creator>
		<pubDate>Fri, 11 Dec 2009 12:59:27 +0000</pubDate>
		<guid isPermaLink="false">http://www.texdev.net/?p=575#comment-1872</guid>
		<description>Hi Joseph,

Thank you for that answer. Unfortunately I don&#039;t plan to use expl3. I will look at it when I become more comfortable with TeX and LaTeX.

Leo</description>
		<content:encoded><![CDATA[<p>Hi Joseph,</p>
<p>Thank you for that answer. Unfortunately I don&#8217;t plan to use expl3. I will look at it when I become more comfortable with TeX and LaTeX.</p>
<p>Leo</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joseph Wright</title>
		<link>http://www.texdev.net/2009/12/09/active-characters-again/#comment-1864</link>
		<dc:creator>Joseph Wright</dc:creator>
		<pubDate>Thu, 10 Dec 2009 21:18:30 +0000</pubDate>
		<guid isPermaLink="false">http://www.texdev.net/?p=575#comment-1864</guid>
		<description>Hello Leo,

If you are only talking about code you use, then the problem is less pressing: the real troubles start when you write code other people use. 

As I explained in my post, if you&#039;re happy to load expl3, then \tl_replace_all_in:Nnn would seem easiest:

\newrobustcmd\multiline[2][c]{%
\setlength{\extrarowheight}{0pt}%
\begin{tabular}{@{}#1@{}}
  \def\temp{#2}%
  \csname\detokenize{tl_replace_all_in:Nnn}\endcsname
    \temp{&#124;}{\tabularnewline}%
  \temp
\end{tabular}
}

I&#039;ve stuck with &quot;traditional&quot; category codes here, hence the \csname construction for calling \tl_replace_all_in:Nnn (the \detokenize avoids any issue if _ or : are active). If you want to avoid loading expl3, then it&#039;s a question of implementing search-and-replace yourself. The expl3 version is efficient but quite intricate!

Joseph</description>
		<content:encoded><![CDATA[<p>Hello Leo,</p>
<p>If you are only talking about code you use, then the problem is less pressing: the real troubles start when you write code other people use. </p>
<p>As I explained in my post, if you&#8217;re happy to load expl3, then \tl_replace_all_in:Nnn would seem easiest:</p>
<p>\newrobustcmd\multiline[2][c]{%<br />
\setlength{\extrarowheight}{0pt}%<br />
\begin{tabular}{@{}#1@{}}<br />
  \def\temp{#2}%<br />
  \csname\detokenize{tl_replace_all_in:Nnn}\endcsname<br />
    \temp{|}{\tabularnewline}%<br />
  \temp<br />
\end{tabular}<br />
}</p>
<p>I&#8217;ve stuck with &#8220;traditional&#8221; category codes here, hence the \csname construction for calling \tl_replace_all_in:Nnn (the \detokenize avoids any issue if _ or : are active). If you want to avoid loading expl3, then it&#8217;s a question of implementing search-and-replace yourself. The expl3 version is efficient but quite intricate!</p>
<p>Joseph</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joseph Wright</title>
		<link>http://www.texdev.net/2009/12/09/active-characters-again/#comment-1863</link>
		<dc:creator>Joseph Wright</dc:creator>
		<pubDate>Thu, 10 Dec 2009 21:09:06 +0000</pubDate>
		<guid isPermaLink="false">http://www.texdev.net/?p=575#comment-1863</guid>
		<description>Hello Marcin,

I was mainly looking at code-level stuff here. For user input, I tend to think that either XeTeX or LuaTeX are much better choices than trying to make UTF-8 work with pdfTeX. LuaTeX is pretty reasonable for general work now, although the lack of higher level LaTeX support is a bit of a pain (of course, if you use ConTeXt all is well).

Joseph</description>
		<content:encoded><![CDATA[<p>Hello Marcin,</p>
<p>I was mainly looking at code-level stuff here. For user input, I tend to think that either XeTeX or LuaTeX are much better choices than trying to make UTF-8 work with pdfTeX. LuaTeX is pretty reasonable for general work now, although the lack of higher level LaTeX support is a bit of a pain (of course, if you use ConTeXt all is well).</p>
<p>Joseph</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: leo</title>
		<link>http://www.texdev.net/2009/12/09/active-characters-again/#comment-1855</link>
		<dc:creator>leo</dc:creator>
		<pubDate>Thu, 10 Dec 2009 03:01:48 +0000</pubDate>
		<guid isPermaLink="false">http://www.texdev.net/?p=575#comment-1855</guid>
		<description>Hi Joseph,

I got a macro as follows:

\begingroup
\catcode`\&#124;=\active
\gdef&#124;{\tabularnewline}
\endgroup
\newrobustcmd\multiline[2][c]{
  \begingroup
  \catcode`\&#124;=\active
  \setlength{\extrarowheight}{0pt}
  \begin{tabular}{@{}#1@{}}
    \scantokens{#2}
  \end{tabular}
  \endgroup
}

How to make this macro safer? thanks.

Leo</description>
		<content:encoded><![CDATA[<p>Hi Joseph,</p>
<p>I got a macro as follows:</p>
<p>\begingroup<br />
\catcode`\|=\active<br />
\gdef|{\tabularnewline}<br />
\endgroup<br />
\newrobustcmd\multiline[2][c]{<br />
  \begingroup<br />
  \catcode`\|=\active<br />
  \setlength{\extrarowheight}{0pt}<br />
  \begin{tabular}{@{}#1@{}}<br />
    \scantokens{#2}<br />
  \end{tabular}<br />
  \endgroup<br />
}</p>
<p>How to make this macro safer? thanks.</p>
<p>Leo</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Marcin</title>
		<link>http://www.texdev.net/2009/12/09/active-characters-again/#comment-1854</link>
		<dc:creator>Marcin</dc:creator>
		<pubDate>Thu, 10 Dec 2009 00:22:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.texdev.net/?p=575#comment-1854</guid>
		<description>&quot;So I’d always favour avoiding active characters, if at all possible.&quot; - so true...  Unfortunately, there&#039;s no (portable) alternative to inputenc (yet)...</description>
		<content:encoded><![CDATA[<p>&#8220;So I’d always favour avoiding active characters, if at all possible.&#8221; &#8211; so true&#8230;  Unfortunately, there&#8217;s no (portable) alternative to inputenc (yet)&#8230;</p>
]]></content:encoded>
	</item>
</channel>
</rss>

