# How to get UTF-8 output with tex4ht under MikTeX 2.9? (Illegal storage address error)

Compiling this MWE (mwe.tex)

\documentclass{article}
\usepackage[greek,italian]{babel}
\usepackage[utf8x]{inputenc}
\begin{document}
\latintext chars with àccéènts
greek chars \greektext ασδφγη
\end{document}


with C:\Program Files (x86)\MiKTeX 2.9\scripts\tex4ht\htlatex.bat mwe.tex (after it was succesfully compiled with pdflatex) produces an ANSI rather than an UTF-8 encoded HTML file. That is, mwe.html once opened shows

chars with ΰccιθnts greek chars ασδφγη

and I can display chars correctly only if I manually change browser encoding to ISO-8859-1.

I also tried a bunch of options for htlatex (the compilation output of htlatex mwe "xhtml, charset=utf-8" " -cunihtf -utf8" is available here), but none solved the problem, any clue?

Since the solution given in answer works fine with TeXLive under Ubuntu, I guess the issue with MikTeX under Windows is due to MikTex.

Here's the log of the test requested by michal.h21:

>tex4ht -he -cunihtf -utf8 mwe
----------------------------
tex4ht.c (2010-12-16-08:39 Windows MiKTeX)
tex4ht -he
-cunihtf
-utf8
mwe
(C:/Program Files (x86)/MiKTeX 2.9/tex4ht/base/win32/tex4ht.env)
(C:/Program Files (x86)/MiKTeX 2.9/fonts/tfm/public/cbgreek/grmn1000.tfm)
(C:/Program Files (x86)/MiKTeX 2.9/tex4ht/ht-fonts/unicode/cbgreek/grmn.htf)
--- error --- Illegal storage address

K y          cmr10   &&


I tried to refresh TeX name database with texhash and mktexlsr but "illegal storage address" problem is still there.

-
please try to run only tex4ht -he -cunihtf -utf8 mwe and paste the log here –  michal.h21 Jun 14 '13 at 16:54
Done, see log in question. –  mmj Jun 14 '13 at 18:04
The source of the error is that miktex doesn't find some files. sourceforge.net/p/miktex/bugs/2350. (It (probably) worked for me when you asked the question due to a local version of the missing file.) –  Ulrike Fischer Feb 4 at 17:51

I don't have miktex, so don't know what means that error message about path, but for utf-8 output, you must run htlatex with:

htlatex mwe "xhtml, charset=utf-8" " -cunihtf -utf8"


result:

chars with àccéènts greek chars ασδφγη

-
Did it, same wrong result and same exit code 1 for same reason. –  mmj Jun 13 '13 at 16:10
@mmj: Michal's command line works fine for me on miktex 2.9. Can you show the complete command line output? –  Ulrike Fischer Jun 13 '13 at 16:17
@mmj as @Ulrike said, please show us complete log file, it may be some problem with your tex4ht instalation –  michal.h21 Jun 13 '13 at 16:26
Thanks, I added in the question a link to the output. I found out that the path problem does not concern tex4ht (it shows up even when I open a command line window!). I also discovered that, with your options, actually no new html file is produced, I was looking at the previously generated html file, due to --- error --- Illegal storage address`, which you will find at the end of output. Such error does not show up compiling without options. –  mmj Jun 13 '13 at 23:25
I could not make your solution work under MikTeX, so I switched to TeXLive under Ubuntu and it worked. In general, switching from MikTeX under Windows to TeXLive under Ubuntu let me solve not only this one, but other severe issues too. –  mmj Dec 2 '13 at 9:03