[texhax] Change \write file's encoding? [Was: How to write a TeX code into file literally]

Yue Wu vanopen at gmail.com
Sun Oct 9 15:37:31 CEST 2011

On Sun, Oct 09, 2011 at 03:07:50PM +0200, Heiko Oberdiek wrote:
> On Sun, Oct 09, 2011 at 08:43:17PM +0800, Yue Wu wrote:
> > Thanks, it solves most part of the problem, but stil has a few left, plz see
> > them below the context.
> > >   \immediate\write\myout{#1\noexpand\endgraf#2}%
> The \noexpand is on purpose. It prevents the expansion and
> adds a space after the command token.
> >   \immediate\write\testout{{\bf#1}\endgraf#2}
> \immediate\write\testout{{\noexpand\bf#1}\noexpand\endgraf#2}
> \noexpand is not needed before unexpandable command tokens
> (plain defines \let\endgraf\par). Thus it is just defensive
> programming in case \endgraf is redefined as macro.

Thanks, it works fine now!

Another question: can I set the output file's encoding from TeX? Say I
want the \write\myout file's encoding is 'gbk', is it possible?

The reason is that, because I want to include the output into TeX at the
end of the same document, and I'm using some macros that needs the
file's encoding is 'gbk'.

Yue Wu

Key Laboratory of Modern Chinese Medicines
Department of Traditional Chinese Medicine
China Pharmaceutical University(中國藥科大學)
No.24, Tongjia Xiang Street, Nanjing 210009, China

More information about the texhax mailing list