Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Open unicode filename

Clayton_Evans
Beginner
1,160 Views

Microsoft uses unicode filenames in NTFS.  http://msdn.microsoft.com/en-us/library/windows/desktop/dd317748%28v=vs.85%29.aspx

My attempts to open a file with a unicode name have proven unsuccessful. I am passing the unicode in from C++, when the program comes to the open statement is fails with a file not found.  If I force the C++ to convert the filename to ANSI characters, it works.  With the Unicode name being passed, I have tried doubling the length of the string being passed to the Fotran from the C++.  The results show below are from this case.

        OPEN ( UNIT =  IOINP, FILE = INFILE, ACTION = 'READ',  FORM = 'FORMATTED', IOSTAT = IOS, ERR = 998 )

...

  998 CONTINUE

      WRITE (16, *) 'IOS = ', IOS, LEN ( INFILE ), INFILE

The output looks like

 IOS =           29          42 B a k k e n   H o r i z o n t a l . d a t

The intell help file states: "The name can be any pathname allowed by the operating system.  Any trailing blanks in the name are ignored."

My experience indicates that the Intel Fortran statement only accepts ANSI characters, Microsoft documentation states that MS uses Unicode file names.  In countries which use a unicode character set, how does one use the Intel Fortran OPEN statement?

Clayton Evans

0 Kudos
4 Replies
Anonymous66
Valued Contributor I
1,160 Views

You are correct that the compiler does not support unicode. We do support multibyte characters though. You can use MBConvertUnicodeToMB to convert the unicode file name to multibyte.

0 Kudos
Clayton_Evans
Beginner
1,160 Views

So if one has a filename with Unicode characters, Intel Fortran cannot open the file.  Correct?

0 Kudos
Anonymous66
Valued Contributor I
1,160 Views

Correct, unless it is converted to multibyte.

0 Kudos
IanH
Honored Contributor III
1,160 Views

You could also open the file using the USEROPEN extension and the underlying CreateFileW api.

0 Kudos
Reply