[Tex/LaTex] How to get UTF-8 output with tex4ht under MikTeX 2.9? (`Illegal storage address` error)

htlatexmiktextex4htunicode

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?

FOLLOW UP

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.

Best Answer

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 ασδφγη