[edited] finished OK MWE
This is mwe.dtx.
% \iffalse (METACOMMENT)
%%
%% ---------------------------------------------------------------------
%%
%% Document class `mwe' to use with LaTeX 2e.
%%
%% ---------------------------------------------------------------------
%%
% \fi
%
% \CheckSum{419}
%% \CharacterTable
%% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%% Digits \0\1\2\3\4\5\6\7\8\9
%% Exclamation \! Double quote \" Hash (number) \#
%% Dollar \$ Percent \% Ampersand \&
%% Acute accent \' Left paren \( Right paren \)
%% Asterisk \* Plus \+ Comma \,
%% Minus \- Point \. Solidus \/
%% Colon \: Semicolon \; Less than \<
%% Equals \= Greater than \> Question mark \?
%% Commercial at \@ Left bracket \[ Backslash \\
%% Right bracket \] Circumflex \^ Underscore \_
%% Grave accent \` Left brace \{ Vertical bar \|
%% Right brace \} Tilde \~}
%%
% ^^A \MakeShortVerb{\|}
% \section{Internals}
%
% \begin{macrocode}
%<class>\NeedsTeXFormat{LaTeX2e}[1995/12/01]
% \end{macrocode}
%
% \iffalse (Don't show this in the doc).
%<*driver>
\ProvidesFile{mwe.drv}
%</driver>
% \fi
% \begin{macrocode}
%<class>\ProvidesClass{./mwe}
[2012/05/24 v1.0
%<class> A mwe class]
% \end{macrocode}
% \iffalse (Omitted from the doc)
%<*driver>
]
%</driver>
% \fi
%
% \subsection{Driver for this document}
%
% This program will extract the following driver from this file:
% \begin{macrocode}
%<*driver>
\documentclass{ltxdoc}
\EnableCrossrefs
%\DisableCrossrefs % Say \DisableCrossrefs if index is ready
\RecordChanges
%\OnlyDescription % Comment out for implementation details
\CodelineIndex
\begin{document}
\DocInput{mwe.dtx}
\end{document}
%</driver>
% \end{macrocode}
% \begin{macro}{\my@op@n}
% \begin{macro}{\my@s@ut}
% \begin{macro}{\protected@write@immediate}
% \begin{macro}{\immediateaddtocontents}
% \begin{macro}{\addtocontentsline}
% \begin{macro}{\my@readwrite@line}
% \begin{macro}{\my@docum@nt}
% \begin{macro}{\my@end@docum@nt}
% \begin{environment}{document}
% \begin{macro}{\my@sym@def}
% \begin{macro}{\my@sym@LANG@def}
% \begin{macro}{\my@s@l@ctl@ngu@g@}
% \begin{macro}{\selectlanguage}
% \begin{macro}{\my@ch@pt@r@}
% \begin{macro}{\@chapter}
% \begin{environment}{symbols}
% \begin{macrocode}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\RequirePackage[T1]{fontenc}%%%%
\RequirePackage[utf8]{inputenc}%
\RequirePackage{xargs}%%%%%%%%%%
\RequirePackage{acronym,suffix,xargs,xifthen,xspace}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\LoadClass[a4paper,10pt,twoside,openright]{report}[2007/10/19]
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommandx\my@op@n[3][addprefix=\global,1=template,2=.txt,3=.tex]{%
\newread\my@file%
\immediate\openin\my@file=#1\myLANG#2%
\newwrite\my@fil@%
\immediate\openout\my@fil@=#1\myLANG#3%
}
\newcommandx\my@s@ut[0][addprefix=\global]{%
\immediate\closein\my@file%
\immediate\closeout\my@fil@%
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Code borrowed from `multitoc.dtx' of CTAN /macros/latex/contrib/ms
%% Copyright (c) [1998..1999] Martin Schr\"oder. All rights reserved.
\newcommand*{\protected@write@immediate}[3]{%
\begingroup
\let\thepage\relax
#2%
\let\protect\string
\edef\reserved@a{\immediate\write#1{#3}}%
\reserved@a
\endgroup
\if@nobreak\ifvmode\nobreak\fi\fi
}
\newcommand*{\immediateaddtocontents}[2]{%
\protected@write@immediate\@auxout
{\let\label\@gobble \let\index\@gobble \let\glossary\@gobble}%
{\string\@writefile{#1}{#2}}}
%%
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\def\addcontentsline#1#2#3{%
\immediateaddtocontents{#1}{\protect\contentsline{#2}{#3}{\thepage}}}
\newcommandx\my@readwrite@line[2][addprefix=\global\protect,1=-1,2=to]{%
\catcode`\\=12\catcode`\{=12\catcode`\}=12\catcode`\$=12%
\catcode`\#=12\catcode`\^=12\catcode`\_=12\catcode`\%=12%
\let\my@var\endlinechar%
\endlinechar=#1%
\immediate\read\my@file#2\my@lin@%
\endlinechar=\my@var%
\catcode`\%=14\catcode`\_=8\catcode`\^=7\catcode`\#=6%
\catcode`\$=3\catcode`\}=2\catcode`\{=1\catcode`\\=0%
\protected@xdef\my@line{\my@lin@}%
\ifthenelse{\equal{\my@line}{}}{}{%
\protected@write@immediate\my@fil@{\relax}{\my@line\@backslashchar\@backslashchar}}%
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\let\my@docum@nt\document
\let\my@end@docum@nt\enddocument
\renewenvironmentx{document}[2][1=pre,2]{%
\my@op@n%
\my@docum@nt%%%%%
\input{#1.tex}%
\ifx\\#2\\\else\selectlanguage{#2}\fi%
\ignorespaces%%%%%%%%%
}{\my@end@docum@nt%
\ignorespacesafterend%
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommandx\my@sym@def[1][addprefix=\global]{%
\expandafter%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommandx\csname#1\endcsname[4][addprefix=\global,3,4]{%
\ifthenelse{\isempty{##3}%
}{\ifthenelse{\isempty{##4}%
}{\acro{##1}{{##2}}%%%%%%%%%
}{\acro{##1}[{##2}]{{##4}}}%
}{\ifthenelse{\isempty{##4}%
}{\acro{##1}{{##2}\acroextra{{##3}}}%%%%%%%%
}{\acro{##1}[{##2}]{{##4}\acroextra{{##3}}}%
}}%
\expandafter\gdef\csname##1\endcsname{\acl{##1}\xspace{}}%%
\expandafter\gdef\csname##1*\endcsname{\acs{##1}\xspace{}}%
}%
}
\newcommandx\my@sym@LANG@def[2][addprefix=\global]{%
\expandafter%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommandx\csname#1#2\endcsname[4][3,4]{%
\ifthenelse{\isempty{##3}%%%%%%%%%%%%%%%%%%%%%%%
}{\@nameuse{#1}{##1}{\@nameuse{#2}{##2}}[][##4]%
}{\@nameuse{#1}{##1}{\@nameuse{#2}{##2}}%%%%%%%%
[\@nameuse{#2}{##3}][##4]%%%
}%
}%
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\let\my@s@l@ctl@ngu@g@\selectlanguage
\renewcommand\selectlanguage[1]{%%%%%%%%%%%
\my@s@l@ctl@ngu@g@{#1}\@nameuse{do\myLANG}}
\let\my@ch@pt@r@\@chapter
\renewcommandx\@chapter[3][1,2,3]{%
\ifthenelse{\isempty{#1}}{%
\GenericError{}{empty chapter name}{%%%
stop}{%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
here.}}%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\ifx\\#3\\\else\selectlanguage{#3}\fi%
\my@ch@pt@r@[#1]{#1}%
\addcontentsline{lof}{chapter}{\thechapter\nobreakspace#1}%
\addcontentsline{lot}{chapter}{\thechapter\nobreakspace#1}%
\ifx\\#2\\\else\label{chp:#2}\fi%
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newenvironmentx{symbols}[1][1]{%
\pagestyle{empty}%%%%%%%
\thispagestyle{empty}%%%
\chapter*{Symbols}%
\addcontentsline{toc}{section}{Symbols}%
\begin{acronym}[{#1}]%
}{\end{acronym}%%%%%%%%%
\clearpage%
}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{environment}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{environment}
This is mwe.ins.
\def\batchfile{mwe.ins}
\input docstrip.tex
\keepsilent
\generateFile{mwe.cls}{t}{\from{mwe.dtx}{class}}
This is ltxdoc.cfg.
\PassOptionsToClass{a4paper}{article}
\AtEndOfPackage{%
\hyphenation{tocprelim semifinal draft}
\RequirePackage{indentfirst}%
\RequirePackage{hyperref}%
}
This is mwe.tex.
% -*- mode: latex; unibyte: nil; coding: utf-8 -*-
\documentclass{./mwe}
\usepackage[romanian]{babel}
\usepackage{newunicodechar}
\newunicodechar{ș}{\c{s}}\newunicodechar{Ș}{\c{S}}
\newunicodechar{ț}{\c{t}}\newunicodechar{Ț}{\c{T}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand\RO[1]{\foreignlanguage{romanian}{#1}\xspace{}}
\newcommand\doRO{\relax}
\xdef\myLANG{RO}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\makeatletter
\my@sym@def{sym}
\@expandtwoargs\my@sym@LANG@def{sym}{\myLANG}
\makeatother
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\title{Minimal Working Example}
\author{acronym}
\begin{document}[preamble][romanian]
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%--------------------------------------------------------------------%
\inputencoding{latin10}
\makeatletter
\newcounter{my@cnt}%
\setcounter{my@cnt}{0}%
\@whilenum\arabic{my@cnt}<24\do{%
\my@readwrite@line%
\stepcounter{my@cnt}%
}
\my@s@ut%
\makeatother
\noindent%
\input{templateRO}
\inputencoding{utf8}
%--------------------------------------------------------------------%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\chapter[Oscilații][osc][romanian]
\HZO~e formula pentru \HZO*.
\end{document}
This is preamble.tex.
% -*- mode: latex; unibyte: t; coding: utf-8 -*-
\maketitle
\begin{symbols}[WORD]
\symRO{HZO}{Apă}[\hfill făcută din 3 elemente și 2 molecule][$H_2O$]
\end{symbols}
\tableofcontents
The sequence is: latex mwe.ins; pdftex -shell-escape mwe.tex #twice
The file templateRO.txt as specified here -- http://en.wikipedia.org/wiki/Romanian_alphabet#Unicode_and_HTML -- contains 8-bit letters with commas, not cedillas.
Thesis
Submitted in Partial Fulfillment of the Requirements for
the Degree of Doctor of Philosophy
in Computer Science
to the Faculty of Engineering of the
University of Rome
by
Conducător științific
Referenți științifici
Ziua susținerii tezei
Acest document este în domeniul public.
Acknowledgements
Dedicație
Keywords
Lista de acronime
Lista de teoreme
Lista de demonstrații
thank s.
\inputencodingwithout problems to include listings in ansi in an utf8-document. I do find this\catcodechanges much more doubtful. What's their purpose? – Ulrike Fischer May 16 '12 at 17:14latin10regime. I don't even ask myself what those\catcodeinstruction are for. – egreg May 16 '12 at 17:15\acrowrites to theaux. But normally this shouldn't be a problem as it will expand non-ascii chars to LICR-commands (\"aetc.). But if the\catcodesare changed you get non-ascii-chars in the aux-file and together with the encoding changes things get messy. – Ulrike Fischer May 16 '12 at 18:13