  {
      if (!os)
      {
-@@ -95,7 +109,7 @@ checkError (ostream &os)
+@@ -95,9 +115,16 @@ checkError (ostream &os)
  
  StdIFStream::StdIFStream (const char fileName[]):
      OPENEXR_IMF_INTERNAL_NAMESPACE::IStream (fileName),
 -    _is (new ifstream (fileName, ios_base::binary)),
-+    _is (new OPENEXR_IMF_INTERNAL_NAMESPACE::ifstream (utf8_to_utf16(std::string(fileName)), std::ios_base::binary)),
++    _is (0),
      _deleteStream (true)
  {
++#ifdef _WIN32
++	std::wstring wfilename = StrUtils::utf8_to_utf16(std::string(fileName));
++	_is = new OPENEXR_IMF_INTERNAL_NAMESPACE::ifstream (wfilename, std::ios_base::binary);
++#else
++	_is = new OPENEXR_IMF_INTERNAL_NAMESPACE::ifstream (fileName, std::ios_base::binary);
++#endif
++
      if (!*_is)
-@@ -106,7 +120,7 @@ StdIFStream::StdIFStream (const char fileName[]):
+     {
+ 	delete _is;
+@@ -106,7 +133,7 @@ StdIFStream::StdIFStream (const char fileName[]):
  }
  
      

     OPENEXR_IMF_INTERNAL_NAMESPACE::IStream (fileName),
     _is (&is),
     _deleteStream (false)
@@ -158,7 +172,7 @@ StdIFStream::clear ()
 
 StdOFStream::StdOFStream (const char fileName[]):
     OPENEXR_IMF_INTERNAL_NAMESPACE::OStream (fileName),
-    _os (new ofstream (fileName, ios_base::binary)),
+    _os (new OPENEXR_IMF_INTERNAL_NAMESPACE::ofstream (utf8_to_utf16(std::string(fileName)), std::ios_base::binary)),
     _deleteStream (true)
 {
     if (!*_os)
@@ -169,7 +183,7 @@ StdOFStream::StdOFStream (const char fileName[]):
 }
 
 

 
 OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_ENTER
 
+#ifdef _WIN32
+
+namespace StrUtils {
+
+std::wstring
+utf8_to_utf16 (const std::string& str)
+{
