 addon/doxywizard/configdoc.cpp |  6 ++++++
 src/config.xml                 |  9 +++++++++
 src/configoptions.cpp          |  8 ++++++++
 src/dot.cpp                    | 19 ++++++++++---------
 src/util.cpp                   | 31 ++++++++++++++++++++++++++++++-
 5 files changed, 63 insertions(+), 10 deletions(-)

diff --git a/addon/doxywizard/configdoc.cpp b/addon/doxywizard/configdoc.cpp
index 1ced316..1a2cf92 100644
--- a/addon/doxywizard/configdoc.cpp
+++ b/addon/doxywizard/configdoc.cpp
@@ -73,6 +73,12 @@ void addConfigDocs(DocIntf *doc)
               "performance problems for the file system.Default value: NO."
           );
   doc->add(
+              "LIMIT_FNAME_WITH_ASCII",
+              "If the LIMIT_FNAME_WITH_ASCII tag is set to YES, doxygen will escape the\n"
+              "filenames named with non ASCII characters like _xE3_x81_x84 for Unicode\n"
+              "U+3044.Default value: YES."
+          );
+  doc->add(
               "OUTPUT_LANGUAGE",
               "The OUTPUT_LANGUAGE tag is used to specify the language in which all\n"
               "documentation generated by doxygen is written. Doxygen will use this\n"
diff --git a/src/config.xml b/src/config.xml
index d73a26c..4fb3aec 100644
--- a/src/config.xml
+++ b/src/config.xml
@@ -279,6 +279,15 @@ Go to the <a href="commands.html">next</a> section or return to the
 ]]>
       </docs>
     </option>
+    <option type='bool' id='LIMIT_FNAME_WITH_ASCII' defval='1'>
+      <docs>
+<![CDATA[
+ If the \c LIMIT_FNAME_WITH_ASCII tag is set to \c YES,
+ doxygen will escape the filenames named with non ASCII 
+ characters like _xE3_x81_x84 for Unicode U+3044.
+]]>
+      </docs>
+    </option>
     <option type='enum' id='OUTPUT_LANGUAGE' defval='English'>
       <docs>
 <![CDATA[
diff --git a/src/configoptions.cpp b/src/configoptions.cpp
index 1dc4a06..d46a1e4 100644
--- a/src/configoptions.cpp
+++ b/src/configoptions.cpp
@@ -98,6 +98,14 @@ void addConfigOptions(Config *cfg)
               FALSE
              );
   //----
+  cb = cfg->addBool(
+             "LIMIT_FNAME_WITH_ASCII",
+              "If the LIMIT_FNAME_WITH_ASCII tag is set to YES, doxygen will escape the\n"
+              "filenames named with non ASCII characters like _xE3_x81_x84 for Unicode\n"
+              "U+3044.Default value: YES.",
+              TRUE
+             );
+  //----
   ce = cfg->addEnum(
               "OUTPUT_LANGUAGE",
               "The OUTPUT_LANGUAGE tag is used to specify the language in which all\n"
diff --git a/src/dot.cpp b/src/dot.cpp
index ffe1028..333a0fa 100644
--- a/src/dot.cpp
+++ b/src/dot.cpp
@@ -665,11 +665,11 @@ static void checkDotResult(const QCString &imgName)
 {
   if (Config_getEnum("DOT_IMAGE_FORMAT")=="png")
   {
-    FILE *f = fopen(imgName,"rb");
-    if (f)
+    QFile f( QString::fromUtf8( imgName ) );
+    if ( f.open( IO_ReadOnly ) )
     {
       char data[4];
-      if (fread(data,1,4,f)==4)
+      if (f.readBlock(data,4)==4)
       {
         if (!(data[1]=='P' && data[2]=='N' && data[3]=='G'))
         {
@@ -684,7 +684,7 @@ static void checkDotResult(const QCString &imgName)
       {
         err("Could not read image `%s' generated by dot!\n",imgName.data());
       }
-      fclose(f);
+      f.close();
     }
     else
     {
@@ -961,24 +961,25 @@ bool DotFilePatcher::run()
     //printf("DotFilePatcher::addSVGConversion: file=%s zoomable=%d\n",
     //    m_patchFile.data(),map->zoomable);
   }
-  QCString tmpName = m_patchFile+".tmp";
-  if (!QDir::current().rename(m_patchFile,tmpName))
+  QString patchName = QString::fromUtf8(m_patchFile.data());
+  QString tmpName = QString::fromUtf8((m_patchFile+".tmp").data());
+  if (!QDir::current().rename(patchName,tmpName))
   {
     err("Failed to rename file %s to %s!\n",m_patchFile.data(),tmpName.data());
     return FALSE;
   }
   QFile fi(tmpName);
-  QFile fo(m_patchFile);
+  QFile fo(patchName);
   if (!fi.open(IO_ReadOnly)) 
   {
     err("problem opening file %s for patching!\n",tmpName.data());
-    QDir::current().rename(tmpName,m_patchFile);
+    QDir::current().rename(tmpName,patchName);
     return FALSE;
   }
   if (!fo.open(IO_WriteOnly))
   {
     err("problem opening file %s for patching!\n",m_patchFile.data());
-    QDir::current().rename(tmpName,m_patchFile);
+    QDir::current().rename(tmpName,patchName);
     return FALSE;
   }
   FTextStream t(&fo);
diff --git a/src/util.cpp b/src/util.cpp
index 735cc33..f135fe4 100644
--- a/src/util.cpp
+++ b/src/util.cpp
@@ -5090,6 +5090,7 @@ bool hasVisibleRoot(BaseClassList *bcl)
 QCString escapeCharsInString(const char *name,bool allowDots,bool allowUnderscore)
 {
   static bool caseSenseNames = Config_getBool("CASE_SENSE_NAMES");
+  static bool useUnicodeFileNames = !Config_getBool("LIMIT_FNAME_WITH_ASCII");
   static GrowBuf growBuf;
   growBuf.clear();
   char c;
@@ -5125,8 +5126,36 @@ QCString escapeCharsInString(const char *name,bool allowDots,bool allowUnderscor
       default: 
                 if (c<0)
                 {
-                  static char map[] = "0123456789ABCDEF";
                   char ids[5];
+                  const unsigned char uc = (unsigned char)c;
+                  if (useUnicodeFileNames && uc <= 0xf7)
+                  {
+                    const char* pt = p;
+                    ids[ 0 ] = c;
+                    int l = 0;
+                    l += uc >= 0xc2 ? 2 : 0;
+                    l += uc >= 0xe0 ? 1 : 0;
+                    l += uc >= 0xf0 ? 1 : 0;
+                    for ( int m = 1; m < l; ++m )
+                    {
+                      unsigned char ct = (unsigned char)*pt;
+                      if (0x80 <= ct && ct <= 0xbf)
+                      {
+                        ids[ m ] = *pt++;
+                        continue;
+                      }
+                      l = 0;
+                      break; // for
+                    }
+                    if ( l )
+                    {
+                      ids[ l ] = 0;
+                      growBuf.addStr( ids );
+                      p += l - 1;
+                      break; // switch
+                    }
+                  }
+                  static char map[] = "0123456789ABCDEF";
                   unsigned char id = (unsigned char)c;
                   ids[0]='_';
                   ids[1]='x';
