\immediate\write and encodings problem
"Mikhail L. Titov" <[email protected]> Thu, 25 Aug 2005 17:09:15 +0400
| Newsgroups | gmane.comp.tex.tetex.general |
|---|---|
| Message-ID | <[email protected]> |
Hello!
Does anyone have any idea how to force teTeX output data into file "AS
IS" ?
I am playing with LatexWiki and Plone (products for Zope). There is a
support for drawing graphs using dot tool from graphviz via latex. And I
want non-latin characters support.
The following code is used to produce .dot file:
\newcommand{\digraph}[3][scale=1]{
\newwrite\dotfile
\immediate\openout\dotfile=#2.dot
\immediate\write\dotfile{digraph #2 {\string#3}}
\immediate\closeout\dotfile
\IfFileExists{#2.ps}
{ \includegraphics[#1]{#2} }
{ \fbox{
\begin{tabular}{l}
The file \texttt{#2.ps} hasn't been created from
\texttt{#2.dot} yet.
\end{tabular}
}
}
}
I have added the following lines into header to support Russian:
\usepackage{mathtext}
\usepackage[T2A]{fontenc}
\DeclareSymbolFont{T2Aletters}{T2A}{cmr}{m}{it}
\usepackage[koi8-r]{inputenc}
\usepackage[russian]{babel}
All text is rendered ok, but the problem is that the conversion of
non-latin characters by teTeX into something weird like
"^^de^^d4^^c5^^ce^^c9^^c5" while writing them into file with \write.
However MikTeX under Windows writes correct .dot files, but teTeX from
Debian Sarge does not.
Another problem is that even in MikTeX I should escape each non-latin
character with the \string to obtain correctly written .dot file :
"\stringч\stringт\stringе\stringн\stringи\stringе"
The whole input .tex file, I played with, follows:
\documentclass[10pt,notitlepage]{article}
\usepackage{amsmath,latexsym,amssymb,amscd,amsthm,amstext,amsfonts}
\usepackage{mathtext}
\usepackage[T2A]{fontenc}
\DeclareSymbolFont{T2Aletters}{T2A}{cmr}{m}{it}
\usepackage[koi8-r]{inputenc}
\usepackage[russian]{babel}
\usepackage[dvips]{color}
\usepackage[dvips]{graphicx}
\usepackage[all]{xy}
\newenvironment{latex}{}{}
\newcommand{\digraph}[3][scale=1]{
\newwrite\dotfile
\immediate\openout\dotfile=#2.dot
\immediate\write\dotfile{digraph #2 {\string#3}}
\immediate\closeout\dotfile
\IfFileExists{#2.ps}
{ \includegraphics[#1]{#2} }
{ \fbox{
\begin{tabular}{l}
The file \texttt{#2.ps} hasn't been created from
\texttt{#2.dot} yet.
\end{tabular}
}
}
}
\newcommand{\ndgraph}[3][scale=1]{
\newwrite\dotfile
\immediate\openout\dotfile=#2.dot
\immediate\write\dotfile{graph #2 {\string#3}}
\immediate\closeout\dotfile
\IfFileExists{#2.ps}
{ \includegraphics[#1]{#2} }
{ \fbox{
\begin{tabular}{l}
The file \texttt{#2.ps} hasn't been created from
\texttt{#2.dot} yet.
\end{tabular}
}
}
}
\begin{document}
\pagestyle{empty}
\begin{latex}
\digraph[scale=0.6]{MyGraph1}{
input
[shape="parallelogram",label="a\stringч\stringт\stringе\stringн\stringи\stringеbb"]
init [shape="circle",style=filled,label=""]
init->b; b->final
final [shape="doublecircle",style=filled,label=""]
}
\end{latex}
\newpage
$$aa тест test$$
\end{document}
--
Mikhail